FindElementByAccessibilityId throws WebDriverException
See original GitHub issueHi Team,
I am using WinAppDriver to automate my windows application. On using FindElementByAccessibilityId to find the element on the application, I am getting the exception “OpenQA.Selenium.WebDriverException: 'An element could not be located on the page using the given search parameters.'”
I am using Inspect tool to inspect the element on the application and getting the value of the property ‘AutomationId’ and providing as string for FindElementByAccessibilityId method.
Could someone help me to understand why I am getting the exception?
Thanks in advance
My Sample Code:
public void TestMethod1()
{
//WinAppDriver and Application started before the test execution
String _appName = "GUIApplication";
AppiumOptions dc= new AppiumOptions();
AppiumOptions mc= new AppiumOptions();
dc.AddAdditionalCapability("platformName", "Windows");
dc.AddAdditionalCapability("app", "Root");
WindowsDriver<WindowsElement> session1= new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), dc);
session1.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(100);
AppiumWebElement element = session1.FindElementByName(_appName);
string AppHandle= element.GetAttribute("NativeWindowHandle");
int HandleInt= int.Parse(AppHandle);
string HandleHex = HandleInt.ToString("x");
mc.AddAdditionalCapability("appTopLevelWindow", HandleHex);
WindowsDriver<WindowsElement> current = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), mc);
current.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(100);
bool result = current.FindElementByAccessibilityId("ABCDEF").Displayed; //Throws Exception
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Can not catch WebDriverException for certain elements
I have the following elements identified in a page object.. public WindowsElement usernameField => _session.FindElementByAccessibilityId(" ...
Read more >"OpenQA.Selenium.WebDriverException" exception thrown ...
WebDriverException " exception thrown sometimes when trying to locate elements by ... FindElementByAccessibilityId(String selector)
Read more >io.appium.java_client.FindsByAccessibilityId java code ...
{@inheritDoc} * * @throws WebDriverException when current session doesn't support the given selector or when * value of the selector is not consistent....
Read more >Casting exception in io.appium.java
I am having an issue while running the following code,it's throwing ... WebDriverException: Returned value cannot be converted to WebElement: ...
Read more >AndroidDriver<T extends org.openqa.selenium.WebElement>
Throws : org.openqa.selenium.WebDriverException - his method doesn't work against native app UI. findElementByPartialLinkText.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@iamkrk Real extracted by WinAppDriver page source can be different from Inspector Could you save the page source and check that control really presents in XML with the expected attributes (use driver.PageSource) and then check that XPath working using http://xpather.com/? Xpath will be something like: //*[@AutomationId=‘FirsatNameTextbox_First Name *’]
Nope. Still throws the exception.
If I just use as below it works.
bool result = current.FindElementByName("First Name *").Displayed;
Am curious to understand why on using FindElementByAccessibilityId throws exception.
Thanks