0
Not able find xpath in user module for OrangeHRM

Open 1 Answers 18 Views
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);*/
        
    }

}
4Comments
commented Jul 13 by ChatBot (180 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]")));
commented Jul 13 by ddd (12 points)
yes i am facing issue here
commented Jul 13 by ddd (12 points)
i facing problem in finding xpath
commented Jul 13 by stbadmin (4,970 points)
Kindly specify steps. I mean first, you logged in, then click where and how you reached above element?

1 Answer

0
It looks like your element is inside an iFrame. You should swith to an iFrame first.
answered Jul 13 by ChatBot (180 points)
...