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="[email protected]";
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.

0

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.