Closed Shahin-M2M closed 4 years ago
Could you attach the full log?
It seems like the elements are not found!
Yes, it looks you got no element.
Could you attach the full log?
It seems like the elements are not found!
Yes, it looks you got no element.
`log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: ./logs/log.txt (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.
Dyanamic: true Device: adb:Android SDK built for x86 Application: APPLICATION URL: null Is Continue: false Instrumented: false Outsid app: false
Get all records Get all records Get all records Get all records Get all records Get all records Get all records Get all records Get all records Get all records `
Could you attach the full log?
It seems like the elements are not found!
Yes, it looks you got no element.
[HTTP] --> POST /wd/hub/session/1b16627d-2be8-429f-a3ac-b6096bed9369/element [HTTP] {"using":"xpath","value":"//[@id='loginWelcomeScreenTitle']"} [debug] [W3C (1b16627d)] Calling AppiumDriver.findElement() with args: ["xpath","//[@id='loginWelcomeScreenTitle']","1b16627d-2be8-429f-a3ac-b6096bed9369"] [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [debug] [BaseDriver] Waiting up to 0 ms for condition [debug] [WD Proxy] Matched '/element' to command name 'findElement' [debug] [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8202/wd/hub/session/8dfb5df6-7e27-4b4d-8218-4bf672e6fc7a/element] with body: {"strategy":"xpath","selector":"//*[@id='loginWelcomeScreenTitle']","context":"","multiple":false} [WD Proxy] Got an unexpected response with status 404: {"sessionId":"8dfb5df6-7e27-4b4d-8218-4bf672e6fc7a","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:102)\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:72)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:51)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerCon... [debug] [W3C] Matched W3C error code 'no such element' to NoSuchElementError [debug] [W3C (1b16627d)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters. [debug] [W3C (1b16627d)] at AndroidUiautomator2Driver.findElOrEls (/usr/local/Cellar/appium/1.16.0/libexec/lib/node_modules/appium/node_modules/appium-android-driver/lib/commands/find.js:75:11) [HTTP] <-- POST /wd/hub/session/1b16627d-2be8-429f-a3ac-b6096bed9369/element 404 40 ms - 416
An update:
find_element(:xpath, "//*[@text='Login']").click
works,
but changing text into id for the same element throws error:
find_element(:xpath, "//*[@id='loginWelcomeLoginButton']").click
An element could not be located on the page using the given search parameters. (Selenium::WebDriver::Error::NoSuchElementError)
Hm, it looks the result of find_element(:xpath, "//*[@id='loginWelcomeLoginButton']")
different from the real device and the emulator.
The case could happen, but it depends on Android OS side.
Probably nothing can do in appium side, unfortunately
Does source result have the element?
Hm, it looks the result of
find_element(:xpath, "//*[@id='loginWelcomeLoginButton']")
different from the real device and the emulator. The case could happen, but it depends on Android OS side. Probably nothing can do in appium side, unfortunatelyDoes source result have the element?
Does source result have the element? -> YES
and when i open the emulator with AppiumStudio and inspect the elements, everything seems to be same as device.
I even tried with an emulator same as the real device (both Pixel 3 API 27), but steel there seems to be a difference in device and emulator searching for elements.
uia2 gets elements via AccessibilityNodeInfo by Android. If AS does not use the API, the result could be different. You can also use espresso driver to get elements via espresso API.
For everyone with the same problem, after 2 days researching and a lot of testing:
On emulator you can just search for the resource-id.
find_element(xpath:, "//*[@resource-id='PACKAGE_NAME:id/ELEMENT_ID']")
Thank you @KazuCocoa for your quick response.
The problem
I've a problem which i cant solve. I started writing my tests with a real device, and if i run the tests with a real device, the tests are running ok.
But when testing with an emulator, i'm getting error:
undefined method "click" for false:FalseClass (NoMethodError)
example command:
find_element(:xpath, path).click
It seems like the elements are not found!
Environment
This is how i set the driver
$driver = Appium::Driver.new(android_caps, false) Appium.promote_appium_methods AppiumWorld
World do AppiumWorld.new end
before and after Cucumber hooks
Before do $driver.start_driver end
After do $driver.driver_quit end