selenium wd + IE - просьба подсказать в чем загвоздка(код вроде правильный)

internet-explorer
java
webdriver
Теги: #<Tag:0x00007fedc0192638> #<Tag:0x00007fedc0192390> #<Tag:0x00007fedc01920e8>

(Евгений Колт) #1

Просьба подсказать где ошибка(она скорее всего не в коде)
наверно какие-то системные настройки без понятия абсолютно ://///
браузер открывается, сайт открывается но поля не находит

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class test {
@Test
public void navigateAndSearch(){
 System.setProperty("webdriver.ie.driver", "C:\\selenium\\IEDriverServer.exe");
 WebDriver driver = new InternetExplorerDriver();
 driver.manage().window().maximize();
 driver.get("http://google.ru");
 WebElement searchfield = driver.findElement(By.cssSelector("body"));
 }
 }

такой результат:

Started InternetExplorerDriver server (32-bit)

2.53.1.0

Listening on port 37896
Only local connections are allowed
сен 21, 2016 10:11:57 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
сен 21, 2016 10:12:00 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == body (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 353 milliseconds
For documentation on this error, please visit: http://seleniumhq.or...ch_element.html
Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:57:44 -0700'
System info: host: 'fazka13', ip: '192.168.0.101', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Dinfo: org.openqa.selenium.ie.InternetExplorerDriver

Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:37896/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}] 
Session ID: 52edc887-e5e9-4c9a-8857-9984eb153514

*** Element info: {Using=css selector, value=body}


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:422)

at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)

at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:631)

at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:369)

at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:466)

at org.openqa.selenium.By$ByCssSelector.findElement(By.java:430)

at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:361)

at test.navigateAndSearch(test.java:16)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

 

Process finished with exit code -1

(Taras) #2

попробуйте добавить driver.manage().timeouts().implicitwait(30, TimeUnit.SECONDS); перед строкой с get(“google…”)


(Владимир) #5

Попробуй с импорта убрать webElement, измени немного код и путь к ie драйверу

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class test {
@Test
public void navigateAndSearch(){
	System.setProperty("webdriver.ie.driver", System.getProperty("user.dir")+"\\lib\\IEDriverServer.exe");
 WebDriver driver = new InternetExplorerDriver();
 driver.get("http://google.ru");
driver.manage().window().maximize();
 driver.findElement(By.cssSelector("body"));
 }
 }