0

Hi I am trying to write a piece of selenium code for the login page of: https://www.phptravels.net/admin. I ab able to find the xpath for log in button but when the code is triggered I get this exception:

org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element ... is not clickable at point (640, 532). Other element would receive the click: ...

The code which I have written is:

public class pageObjectRepo {

WebDriver driver;
String mail="admin@phptravels.com";
String pass="demoadmin";
public pageObjectRepo(WebDriver driver)
{
    this.driver=driver;
}

By email = By.xpath("(//*[@name='email'])[1]");
By pwd = By.xpath("(//*[@name='password'])[1]");
By loginbtn= By.xpath("//button[@type='submit']");

public void login() throws InterruptedException {
    driver.findElement(email).sendKeys(mail);
    Thread.sleep(1000);
    driver.findElement(pwd).sendKeys(pass);
    driver.manage().window().maximize();
    Thread.sleep(5000);
    driver.findElement(loginbtn).click();
}

login method is called in the actual test class.

2 Answers2

0

I would try using the name locator instead of xpath which looks wrong.

By email = By.name("email]");

Try the same for password as well.

JerryBringer
  • 150
  • 1
  • 1
  • 8
0

Do not use Thread. Sleep in order to wait for your web elements. Instead, use explicit wait. Moreover before clicking on the button check if the button is displayed and is enabled and then perform the click.

Zmehak
  • 11
  • 4