Hello, I’d like to find way how to simply tap on the OK button.
I am using
driver.findElementById(“android:id/button1”).click();
where ‘android:id/button1’ is resource-id.
Seems as this command is not executed at all and no click is performed.
Hi,
Have you ever tried with switchToAlert…
Alert alert = driver.switchTo().alert();
alert.accept(); (or) driver.findElementById(“android:id/button1”).click();
public void ClickPopupButton(string buttonText)
{
//wait up to 5 seconds for the alert to appear
for (var i = 0; i < 5; i++)
{
if (this.IsAlertPresent())
{
IList<IWebElement> buttonCells = driver.FindElement(eAlertButtonCollection).FindElements(By.ClassName("android.widget.Button"));
foreach (IWebElement cell in buttonCells)
{
if (cell.Text.Contains(buttonText, StringComparison.InvariantCultureIgnoreCase))
{
cell.Click();
break;
}
}
break;
}
}
Try to put some wait before clicking on OK button and if it is having text attribute as ‘OK’, then have a try with
driver.findElement(By.name(“OK”)).click();
Yeah, when automating the simulator or real device doesn’t perform fast operations as like real device app. So putting wait and driver.findelement(By.xpath(“xapath address”).click(); will work. In my experience sometime Byname doesn’t work and sometime ByXpath so we should try to use whatever is possible.