2017-09-19 17 views
0

ブラウザ:IE11 IEDriver:IEDriverServer_x64_3.3.0 コードスニペット:IEDriver常にthowsはNoSuchElementException

public class DownloadinIE 
{ 
    long timeout = 1000; 
    public String classname = this.getClass().getSimpleName(); 
    String date = new SimpleDateFormat("yyyy_MM_dd_HH").format(Calendar.getInstance().getTime()).toString(); 
    String downloadPath = \\ur download path; 
    public WebDriver driver; 

    @BeforeMethod 
    public void setup() 
    { 
System.setProperty("webdriver.ie.driver","\\IEDriverServer.exe"); 
     driver = new InternetExplorerDriver(); 
    } 
    @Test 
    public void download() throws InterruptedException 
    { 
     driver.get("https://www.eclipse.org/downloads/?"); 
     Thread.sleep(10000); 
     driver.findElement(By.cssSelector("[title='64 bit Download']")).click(); 
     Thread.sleep(3000); 
     driver.findElement(By.cssSelector(".fa.fa-download")).click(); 
     Thread.sleep(3000); 
     BaseLibrary.verifyFileDownloaded(downloadPath); 
    } 
} 

エラーメッセージ:ファイルが完全にダウンロードされている場合

org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == .fa.fa-download (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 961 milliseconds 
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html 
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46' 
System info: host: 'A', ip: '192.168.0.102', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_74' 
Driver info: 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:17524/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}] 
Session ID: f75c788e-f130-4531-9f0a-a4bc714d9e76 
*** Element info: {Using=css selector, value=.fa.fa-download} 
    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:206) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:492) 
    at org.openqa.selenium.By$ByCssSelector.findElement(By.java:430) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355) 
    at reports.WaitAndDownloadIE.download(WaitAndDownloadIE.java:45) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) 
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:669) 
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:877) 
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1201) 
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) 
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) 
    at org.testng.TestRunner.privateRun(TestRunner.java:776) 
    at org.testng.TestRunner.run(TestRunner.java:634) 
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:425) 
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:420) 
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:385) 
    at org.testng.SuiteRunner.run(SuiteRunner.java:334) 
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1318) 
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1243) 
    at org.testng.TestNG.runSuites(TestNG.java:1161) 
    at org.testng.TestNG.run(TestNG.java:1129) 
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114) 
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) 
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) 

verifyFileDownloaded方法を検証します。私の問題は、ドライバが最初の要素のクリックから何らかのオブジェクトを認識していないことです。このテストは、FirefoxとChromeでうまくいきます。ここでの問題は何ですか?あなたの提案を提供してください。

私のアプリケーションは、同様の機能のためにIEでテストする必要があります。それで私がこのようにしている理由

+0

Webdriver with Java – crawler

答えて

0

あなたのInternetExplorer =>インターネットオプション=>セキュリティがすべて無効になっているか、レベルが低いことを確認してください。これは私を助けた。

+0

お返事ありがとうございます。あなたの提案はIEでの実行に必須で、私はそれを受け入れます。しかし、私の場合、それは助けにならなかったし、別のアプローチを試してみました。 – crawler

関連する問題