I am making scenario to automatizate some actions on this site https://csgo500.com/
Code of my class:
package scenario;
import managers.loaders.CheckBy;
import driver.sleep.DriverSleeper;
import exceptions.NotNowException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class CSGO500Scen implements SiteScenarioInt{
private WebDriver driver;
public CSGO500Scen(WebDriver driver){
this.driver = driver;
}
public void gamble() throws NotNowException {
driver.get("https://csgo500.com/");
CheckBy.id("gotit-btn");
driver.findElement(By.id("gotit-btn")).click(); //accept terms of use
DriverSleeper.sleep(3);
CheckBy.id("content-login");
DriverSleeper.sleep(3);
driver.findElement(By.xpath("//*[@id=\"content-login\"]")).click(); //HERE IS A PROBLEM
CheckBy.className("btn_green_white_innerfade");
driver.findElement(By.className("btn_green_white_innerfade")).click(); //login with steam
CheckBy.className("nav-rewards");
driver.findElement(By.className("nav-rewards")).click();
if(!isActive()){
throw new NotNowException("CSGO500.com");
}
else{
while(true){
DriverSleeper.sleep(3);
if (!isActive()){
break;
}
}
}
}
private boolean isActive(){
if (driver.findElement(By.id("reward-claim-submit-disabled")).getAttribute("style").equals("display: none;")){
return true;
}
else{
return false;
}
}
}
First step is to Accept Use Terms. Ok, it's done, but when i want to click on "Login" button, i get following error(Login button id is "content-login") :
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element <a id="content-login" href="http://ift.tt/2royEJ8" data-lang="login" class="" data-__original="
...
" data-__trid="1000018" data-__translated="en">Login</a> is not clickable at point (946, 33). Other element would receive the click: <div id="login-content">...</div>
It writes that this page contains one more element with the same id. I have written Test to get number of elements with this id:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class test {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user\\IdeaProjects\\sitescen\\src\\main\\resources\\chromedriver.exe" );
WebDriver driver = new ChromeDriver();
driver.get("http://ift.tt/1UtLAUt");
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
System.out.print(driver.findElements(By.xpath("//*[@id=\"content-login\"]")).size());
}
}
I got output:
1
So, i have only one element with the same id, and no elements arround this button.
To prevent errors of loading, i use sleep
of my DriverSleeper
class which accept number of seconds to sleep.
Finally, i don't know, how to click this button, and hope, that you help me.
Aucun commentaire:
Enregistrer un commentaire