Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
131 views
by Contributing Tester (12 points)
edited by

Please help me with the below code snippet. Supposed to be the below code will delete all the user-created profiles (User created profile has the delete-icon right next to the profile name) and if there's no user-created profile left for deletion, it should go back to the previous screen. The below code delete all the user-created profile which is expected, however it is generating an : "NoElementExceptionFound"  for  "MobileElement 

DELTestProfile = driver.findElement(By.xpath("//android.widget.Image[@text ='icon-delete']"))"

//MANAGE PROFILE 

MobileElement manProfile = driver.findElement(By.xpath("//android.view.View[@text = 'Manage Profiles']"));

manProfile.click();

//LOOP - DELETE USE-CREATED PROFILE

try {

while (driver.findElement(By.xpath("//android.widget.Image[@text ='icon-delete']")).isDisplayed()) {    

MobileElement DELTestProfile = driver.findElement(By.xpath("//android.widget.Image[@text ='icon-delete']"));



 DELTestProfile.click();

 Thread.sleep(3000);

//CONFIRMATION TO DELETE

 MobileElement ConfirmDELETEProfile = driver.findElement(By.xpath("//android.widget.Button[@text='DELETE']"));

ConfirmDELETEProfile.click();

 Thread.sleep(3000);

   }

 } catch (Exception e){} MobileElement backProfile = driver.findElement(By.xpath("//android.widget.Button[@content-desc = 'back']"));









backProfile.click();
by Master (1.2k points)
have you tried using explicit wait to wait for the element?

Maybe the element is taking time to load.

Please log in or register to answer this question.

...