Very new to Automated testing.
Need the SWITCH option to be selected.
Struggling to write the code for it (Android).
Test failed due to this pop-up. "Switch" option needs to be selected. Below are my test steps. Test fails at step "When I navigate to Notification Center after login"
CODE for that step in my java file.
According to the below code if element notificationIconAfterLogin exists then click notificationHeader.
Here notificationIconAfterLogin has xpath: (//android.widget.ImageView 1 ) 3
notificationHeader has xpath: //*[@text='Notification Centre']
Now notificationIconAfterLoginAndroidOptional has xpath: (//android.view.ViewGroup 3 ) 1
switchDeviceBtn has xpath: //*[@text='SWITCH']
@Given("^I navigate to Notification Center after login$")
public void iNavigateToNotificationCenterAfterLogin() throws Exception {
if (elementExists(notificationIconAfterLogin)) {
loopClickUntilFound(notificationIconAfterLogin, notificationHeader);
} else {
loopClickUntilFound(notificationIconAfterLoginAndroidOptional, switchDeviceBtn);
}
waitFor(3);
screenshot(); // Cap screen in notification center
}
My SWITCH option doesn't get selected. Need help to fix the code.
what am I missing here?? is there any other way?
in the method iNavigateToNotificationCenterAfterLogin() first check if Switch option is displayed and then click on the Switch button and then perform your regular operation
Sample Apium-Java Code:
if(driver.findElements(By.xpath("//*[@text='SWITCH']")).size()==1)
{
driver.findElement(By.xpath("//*[@text='SWITCH']")).click()
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.