Reputation: 57
I have to automate an iOS pega mobile app, there I have a field which i need to click. But that field in set to visible "false". Is there a way where i can click on that element?
String selector = "type=='XCUIElementTypeStaticText' AND rect.x==101 AND rect.y==150 AND(visible == 0 OR enabled == 1)";
MobileElement timeEle = driver.findElementByIosNsPredicate(selector);
timeEle.click();
xpath shown in Appium,
//XCUIElementTypeOther[@name="Center Panel, region"]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[4]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther
Upvotes: 1
Views: 2258
Reputation: 1115
When working with hidden elements, you'll typically want to use javascript to interact with them.
In java, and with your example, this would look like
import org.openqa.selenium.JavascriptExecutor; # added to the top of the script
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click()", timeEle);
Upvotes: 1