Reputation: 3
I am having trouble with automating test on website https://casino.efortuna.ro/en/
whatever I do, selenium is not able to find inputs for username/password
I have already tried driver.switchTo().activeElement() and driver.switchTo().frame(0) and nothing seems to be working.
this code is supposed to find them and fill them but will always fail with
"no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="view389"]/div/div/div[2]/div/div[2]/div/form/div[1]/div[1]/div/input"}"
public CasinoMainPage openLoginForm() {
WebElement loginBtn = driver.findElement(By.xpath("//*[@id=\"application\"]/div[3]/div[1]/div[4]/div[1]/div/div/div[2]/div[2]/button"));
loginBtn.click();
return this;
}
public CasinoMainPage fillUsername(String username) {
WebElement loginField = driver.findElement(By.xpath("//*[@id=\"view389\"]/div/div/div[2]/div/div[2]/div/form/div[1]/div[1]/div/input"););
loginField.sendKeys(username);
return this;
}
public CasinoMainPage fillPassword(String password) {
WebElement passwordField = driver.findElement(By.xpath("//*[@id=\"view185\"]/div/div/div[2]/div/div[2]/div/form/div[1]/div[2]/div/input"););
passwordField.sendKeys(password);
return this;
}
//this method is called from @Test and fails on Fillusername()
public CasinoMainPage login() {
goToMainPage();
waitFor(By.xpath("//*[@id=\"application\"]/div[3]/div[1]/div[4]/div[1]/div/div/div[2]/div[2]/button");,Const.DEFAULT_TIMEOUT);
openLoginForm();
driver.switchTo().activeElement();
fillUsername("login");
fillPassword("password");
commitLogin();
return this;
}
can you please help me? I can't find out what am I doing wrong. Thanks in advance.
Upvotes: 0
Views: 1356
Reputation: 193088
Here is the Answer to your Question:
You can consider to change the following:
Login
button on Homepage:
WebElement loginBtn = driver.findElement(By.xpath("//button[@class='btn btn_action_login btn_size_small fn-login']"));
Username
field:
WebElement loginField = driver.findElement(By.name("userName"));
Password
field:
WebElement passwordField = driver.findElement(By.name("password"));
LOG IN
button:
WebElement LOG_IN = driver.findElement(By.xpath("//button[@class='btn fn-login-btn btn_type_popup-login']"));
Let me know if this Answers your Question.
Upvotes: 1