Issue
I've run into an issue with our current mobile project where our click wont interact with a save button on our device page. This is currently the only scenario we have run into this with so far. I've tried various xpaths/locators including placing coordinates into the xpath itself with no luck. Additionally I noticed that clickable is set to false so I also tried the attribute above the save text, which was set to clickable true and didn't have any luck there either. Any ideas would be welcome! For perspective, I need to be able to click the save button. When it runs, it it says it clicks and attempts our validation, but nothing actually happens on the emulator.
Pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId></groupId>
<artifactId>framework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<testng.files.location>src/TestSuites/</testng.files.location>
<testng.file>testng.xml</testng.file>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<gridUrl>http://selenium-hub-1.qa.automation.vpc:4444/wd/hub</gridUrl>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${SuiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.31</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-to-slf4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.19.0</version>
</dependency>
</dependencies>
</project>
Method:
/**
* Registers a real lock from locations screen
*
* @throws InterruptedException
*/
public void addLock(String serialNumber, String model, String lockName) throws InterruptedException{
logg.info("Adding a device");
withAction.mobileClick(btnAddLock);
logg.info("Add Lock button is clicked");
logg.info("Clicking Scan QR Code button");
withAction.mobileClick(btnScanQRCode);
logg.info("Sending a serial number into the enter serial number manually field");
logg.info("Clicking Enter Serial Number Manually button");
withAction.mobileClick(btnEnterSNManually);
logg.info("Validating Enter serial number is displayed");
withAssert.mobileStringExists(txtEnterSN, "Enter serial number");
withAction.sendText(btnEnterSN, serialNumber);
logg.info("Clicking a model tile");
WebElement element = appiumDriver.findElement(By.xpath("//*[@text='" + model + "']"));
withAction.mobileClick(element);
logg.info("Clicking continue button");
withAction.mobileClick(btnContinue);
logg.info("Validating the next screen that is showing You are almost done! text");
withAssert.mobileStringExists(txtAlmostDone, "You are almost done!");
logg.info("Sending a name to a lock");
withAction.sendText(btnLockName, lockName);
withAction.mobileBack();
logg.info("Validating save button");
withAssert.mobileStringExists(txtSave, "Save");
Thread.sleep(3000);
logg.info("Clicking save lock button");
withAction.mobileClick(btnSaveLock); //this is where it needs to click
logg.info("Validating success message");
withAssert.mobileStringExists(txtSuccess, "Success!");
logg.info("Clicking next button");
withAction.mobileClick(btnNext);
logg.info("Clicking done button");
withAction.mobileClick(btnDone);
logg.info("Validating Lock Setup Not Finished message");
withAssert.mobileStringExists(txtSuccess, "Lock Setup Not Finished");
logg.info("Clicking I'll connect my lock later button");
withAction.mobileClick(btnConnectLater);
}
MobileClick Method
/**
* clicks an element
*
* @param element
*/
public void mobileClick(WebElement element) {
logg.info("Clicking an element by xpath");
WebDriverWait wait = new WebDriverWait(appiumDriver, Duration.ofSeconds(30));
wait.until(ExpectedConditions.elementToBeClickable(element)).click();
}
Solution
For anyone else that might be facing this - This actually ended up being an issue with an overlay in the application. Our solution was to tap somewhere on the screen based on coordinates and then tap on the button.
Answered By - K White
Answer Checked By - David Marino (JavaFixing Volunteer)