appium-for-mac
appium-for-mac copied to clipboard
find_elements is not working
Hi There,
I am trying to use find_elements to find elements with xpath in Safari Mac App but it is not working and I am always getting the below error:
/usr/local/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/response.rb:69:in assert_ok': An element could not be located on the page using the given search parameters (Selenium::WebDriver::Error::NoSuchElementError)
Although when I try to use "find_element" instead with the same xpath, it is working and returning the element.
Am I doing something wrong?
I think this is a known issue. Maybe @stuartbrussell-intuit can comment?
It should be fixed now after the merge of Fixes the post_elements return #31
@davidmokos You say "We can now use the selenium driver.find_elements_by_id() without problems." I am working with a java framework, so should the equivalent, driver.findElements(By.id("[AXDOMIdentifier]")) also be working? Or am I misunderstanding the functionality/fix here? It is not working for me with a build from the latest.
Is a full AXPath always required to identify "WebElements" via By.xpath or is there working functionality to find an element via [java] findElements(By.id()) or [py] ( find_elements_by_id() ) by passing an AXDOMIdentifier attribute value? That's what I took your statement to mean. Thanks.
@btdaniel2 Hi, yes driver.findElements(By.id... is the equivalent and it should be working. The fix is currently in master, but there is no new release with this fix, so you need to clone the repo and build the code yourself with xcode, I guess.
@davidmokos Well, yes, Ive done that, but I'm receiving an org.openqa.selenium.NoSuchElementException with the following code:
String axObject = "/AXApplication[@AXTitle='TestApp']/AXWindow[@AXSubrole='AXDialog']/AXScrollArea[0]/AXWebArea[0]/AXTabGroup[@AXDOMIdentifier='product']/AXRadioButton[@AXTitle='title' and @AXDOMIdentifier='product-name']";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platform", "Mac");
try {
driver = new RemoteWebDriver(new URL("http://localhost:4622/wd/hub"), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
}
// this line works as expected
driver.findElement(By.xpath(axObject)).click();
// this line throws the execption
driver.findElement(By.id("product-name")).click();
INFO: Detected dialect: OSS Exception in thread "main" org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 8.40 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800' System info: host: 'l', ip: '', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144' Driver info: org.openqa.selenium.remote.RemoteWebDriver Capabilities [{nativeEvents=true, locationContextEnabled=false, webStorageEnabled=false, browserName=Mac, takesScreenshot=true, javascriptEnabled=true, databaseEnabled=false, version=10.12.6, platform=MAC}] Session ID: riFzuBz4 *** Element info: {Using=id, value='product-name'}
@btdaniel2 Ok, this seems to be a different issue. What the latest merge fixed was the ability to search for multiple elements (using driver.find_elements...). The functionality to search for one element using the id or xpath was not touched. I don't know why is this failing for you, my guess is that in the xpath, there is AXDOMIdentifier which is maybe not the same as AXIdentifier, but I can't tell for sure. Maybe @stuartbrussell-intuit can help?
@davidmokos I see. I didn't realize the "id" correlated to "AXIdentifier" rather than AXDOMIdentifier, since that is the only attribute with "Identifier" that appears in the AXPath for the application I'm working with. Is there any implementation for finding elements by a specific attribute value with the AXPath? So xpath == the full AXPath, id == an AXIdentifier attribute value? Are there any other "By" methods implemented with a corresponding AX equivalent? Or can partial AXPath's be used in some way I haven't seen demonstrated?
find_elements_by_id is not properly working, return dict: {'message': 'Success\t The command executed successfully.'} how to find many elements?
Yeah I'm seeing this problem too. Guess I'll try to fix this.