cindy87
cindy87

Reputation: 57

How to click on an element which is visible=false in an ios mobile app

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?

Image of the mobile screen

  1. Approach (1) I used Click on the Time(secs) text field, but this is set to visible false

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();

  1. Approach (2) I used Click on the "Clock" icon, even for that i used predicate string still it's not working.

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

Answers (1)

scilence
scilence

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

Related Questions