我已经放置了linktext及其更正,但错误就像Element ...在点(750,38)处无法点击。
我试过的代码:
driver.get("https://staging.keela.co");
WebDriverWait wait = new WebDriverWait (driver, 15);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Log In")));
element.click();
//waiting for to load
driver.findElement(By.xpath("//input[@id='login-email']")).sendKeys("bandana@yopmail.com");
driver.findElement(By.xpath("//input[@id='login-password']")).sendKeys("keela");
driver.findElement(By.xpath("//button[@class='btn btn-sm btn-block btn-primary']")).click();
答案 0 :(得分:1)
我在您的代码中注意到,点击Login in
按钮后,您没有提供任何wait
。所以由于这个原因,你得到一个错误。
我在下面尝试了相同的代码,它对我来说很好。
请尝试以下代码。
driver.get("https://staging.keela.co");
driver.manage().window().maximize();
new WebDriverWait(driver, 15).until(ExpectedConditions.elementToBeClickable(By.linkText("Log In")));
driver.findElement(By.linkText("Log In")).click();
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='login-email']")));
driver.findElement(By.xpath("//input[@id='login-email']")).sendKeys("bandana@yopmail.com");
driver.findElement(By.xpath("//input[@id='login-password']")).sendKeys("keela");
driver.findElement(By.xpath("//button[@class='btn btn-sm btn-block btn-primary']")).click();
参考图片
答案 1 :(得分:1)
它在Chrome中工作正常,我只是增加了等待时间并用于点击:
System.setProperty("webdriver.chrome.driver", "E:\\software and tools\\chromedriver_win32\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://staging.keela.co/");
WebDriverWait wait = new WebDriverWait (driver, 50);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Log In")));
element.click();
//waiting for to load
driver.findElement(By.xpath("//input[@id='login-email']")).sendKeys("bandana@yopmail.com");
driver.findElement(By.xpath("//input[@id='login-password']")).sendKeys("keela");
driver.findElement(By.xpath("//button[@class='btn btn-sm btn-block btn-primary']")).click();
实际上,您的网站需要花费太多时间才能加载,以便缩短等待时间
答案 2 :(得分:0)
尝试使用JavascriptExecutor执行点击操作
//Creating the JavascriptExecutor interface object by Type casting
JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement button = driver.findElement(By.xpath("//button[@class='btn btn-sm btn-block btn-primary']"));
//waiting for to load
driver.findElement(By.xpath("//input[@id='login-email']")).sendKeys("bandana@yopmail.com");
driver.findElement(By.xpath("//input[@id='login-password']")).sendKeys("keela");
//Perform Click using JavascriptExecutor
js.executeScript("arguments[0].click();", button);