Mình đang tìm hiểu Selenium Webdriver trong đoạn code mong muốn của mình là khi chạy sẽ tự đăng nhập vào account google nhưng chỉ điền được Email thì nó lại báo lỗi này. Các bạn hướng dẫn giúp minh.
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException:
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'W2VN-DINHHQ', ip: '192.168.104.48', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20161208153507, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=7688, browserVersion=50.1.0, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt}]
Session ID: c68b6ab4-21e3-4d65-acdf-c31ff50de7a0
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at pageObjects.Login_Google.Login_Blank_Password(Login_Google.java:51)
at pageObjects.Login_Google.main(Login_Google.java:19)
//
package pageObjects;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
import org.eclipse.jetty.util.log.Log;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Login_Google {
public static void main(String[] args) throws InterruptedException, Exception{
//Login_Blank_Email();
Login_Blank_Password();
}
public static void Login_Blank_Email(){
System.setProperty("webdriver.gecko.driver", "geckodriver-v0.11.1-win64/geckodriver.exe");
WebDriver driver = new FirefoxDriver ();
driver.get("https://accounts.google.com/");
driver.findElement(By.name("Email")).sendKeys("");
driver.findElement(By.name("signIn")).click();
String content_Error =driver.findElement(By.id("errormsg_0_Email")).getText();
// verify
Assert.assertEquals(content_Error, "Input Again your Email.");
//close browser
driver.close();
}
public static void Login_Blank_Password() throws InterruptedException{
System.setProperty("webdriver.gecko.driver", "geckodriver-v0.11.1-win64/geckodriver.exe");
WebDriver driver_1= new FirefoxDriver();
driver_1.get("https://accounts.google.com/");
// Input Email
driver_1.findElement(By.name("Email")).sendKeys("dinhmmo");
driver_1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver_1.findElement(By.name("signIn")).click();
Thread.sleep(50);
WebElement checkRemeber = driver_1.findElement(By.name("PersistentCookie"));
if (checkRemeber.isSelected()==true){
checkRemeber.click();
}
else
{
//Input Password
driver_1.findElement(By.id("Passwd")).sendKeys("password");
driver_1.findElement(By.id("signIn")).click();
driver_1.close();
}
}
}