I am trying to do a wait for element to be visible before I try to click it. My tests fail with NoSuchElementException if I don't wait. Right now I am doing a wait by text but I want to be able to wait for the accessibilityId. I noticed that accessibilityId is not an option in By. How do I handle it?
_driver = new AndroidDriver<IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"),capability);
var wait = new WebDriverWait(_driver,new TimeSpan(0,0,0,15));
wait.Until(ExpectedConditions.ElementIsVisible(
By.XPath("//android.widget.TextView[@text='Bypass Sign In (Testing Only)']")));
_driver.FindElementByXPath("//android.widget.TextView[@text='Bypass Sign In (Testing Only)']").Click();;
Update: I noticed that there is a MobileBy class with a By strategy for Accessibility Id however when I try to implement the wait with it my test fails immediately with a NoSuchElementException. Once I have waited long enough using the xpath and then do a click by _driver.FindByAccessibilityId it seems to recognize that button and click on it.
Failing Code below.
'var wait = new WebDriverWait(_driver, new TimeSpan(0, 0, 0, 45));
wait.Until(ExpectedConditions.ElementIsVisible(MobileBy.AccessibilityId("Button_SignIn")));
_driver.FindElementByAccessibilityId("Button_SignIn").Click();'
Working Code
`var wait = new WebDriverWait(_driver, new TimeSpan(0, 0, 0, 45));
wait.Until(ExpectedConditions.ElementIsVisible(
By.XPath("//android.widget.TextView[@text='Bypass Sign In (Testing Only)']")));
_driver.FindElementByAccessibilityId("Button_SignIn").Click();`