PhantomJS немогу проделать действия с сайтом

 
 
 
Сообщения:14
Здравствуйте, помогите пожалуйста, в коде внизу если выбрать chrome драйвер, то действия проделываются, если же выбрать phantomjs то пишет ошибку. Помогите новичку.

Код:
		DesiredCapabilities caps = new DesiredCapabilities();
		caps.setJavascriptEnabled(true);
		caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C:\\Users\\user\\Downloads\\phantomjs-2.1.1-windows\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
				
		WebDriver driver = new PhantomJSDriver();
		
		driver.manage().window().setSize(new Dimension(1024, 768));
		driver.get("http://mail.google.com");
		driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
		driver.findElement(By.cssSelector("#Email")).sendKeys("[email protected]");
		driver.findElement(By.cssSelector("#next")).click();
		driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
		driver.findElement(By.cssSelector("#Passwd")).sendKeys("000000");
		driver.findElement(By.cssSelector("#signIn")).click();
		driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
		File scrFile=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
		FileUtils.copyFile(scrFile, new File("C:\\Users\\user\\Desktop\\scrshot.png"));
		driver.close();
		driver.quit();



Ошибка:

Exception in thread "main" org.openqa.selenium.InvalidElementStateException: {"errorMessage":"Element is not currently interactable and may not be manipulated","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"48","Content-Type":"application/json; charset=utf-8","Host":"localhost:39960","User-Agent":"Apache-HttpClient/4.5.2 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"id\":\":wdc:1483575902882\",\"value\":[\"000000\"]}","url":"/value","urlParsed":{"anchor":"","query":"","file":"value","directory":"/","path":"/value","relative":"/value","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/value","queryKey":{},"chunks":["value"]},"urlOriginal":"/session/5ed79190-d2dd-11e6-a9f0-75778d816a60/element/:wdc:1483575902882/value"}}
Command duration or timeout: 543 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'user-ПК', ip: '000.000.00.0', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=2.1.1, platform=XP, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, acceptSslCerts=false, driverVersion=1.2.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 5ed79190-d2dd-11e6-a9f0-75778d816a60
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
	at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:98)
	at t1.PhantomJSDemo.main(PhantomJSDemo.java:40)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'user-ПК', ip: '000.000.00.0', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: RemoteWebDriver
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:142)
	... 4 more
Caused by: org.openqa.selenium.InvalidElementStateException: {"errorMessage":"Element is not currently interactable and may not be manipulated","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"48","Content-Type":"application/json; charset=utf-8","Host":"localhost:39960","User-Agent":"Apache-HttpClient/4.5.2 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"id\":\":wdc:1483575902882\",\"value\":[\"000000\"]}","url":"/value","urlParsed":{"anchor":"","query":"","file":"value","directory":"/","path":"/value","relative":"/value","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/value","queryKey":{},"chunks":["value"]},"urlOriginal":"/session/5ed79190-d2dd-11e6-a9f0-75778d816a60/element/:wdc:1483575902882/value"}}
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'user-ПК', ip: '000.000.00.0', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: unknown
 
Модераторы:Нет
Сейчас эту тему просматривают:Нет