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

0 like 0 dislike
1.2k views
by Contributing Tester (12 points)
retagged by
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class test {
     public static WebDriver driver;
    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub
        
        
          String URL= "http://divyatad.trials621.orangehrmlive.com";
          
          driver= new FirefoxDriver();
          driver.manage().window().maximize();
          driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
          driver.get(URL);
        driver.findElement(By.id("txtUsername")).sendKeys("Admin");
          driver.findElement(By.id("txtPassword")).sendKeys("ah4Omutr");
          driver.findElement(By.id("btnLogin")).click();
         Thread.sleep(1000);
    
         WebDriverWait wait= new WebDriverWait(driver,30);
         Actions act=new Actions(driver);
         
    WebElement e1=driver.findElement(By.xpath("//*[@id='menu_admin_viewAdminModule']/child::a/span[2]"));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='menu_admin_viewAdminModule']/child::a/span[2]")));
    act.moveToElement(e1).click();
act.perform();
    
/*JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", e1);*/
        
    }

}
by The go-to Tester (222 points)
Is this the line where you are facing the issue?

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='menu_admin_viewAdminModule']/child::a/span[2]")));
by Contributing Tester (12 points)
yes i am facing issue here
by Contributing Tester (12 points)
i facing problem in finding xpath
by The go-to Tester (181 points)
Kindly specify steps. I mean first, you logged in, then click where and how you reached above element?

1 Answer

0 like 0 dislike
by The go-to Tester (222 points)
It looks like your element is inside an iFrame. You should swith to an iFrame first.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...