Internet Explorer не может найти элемент на странице

Привет) Подскажите пожалуйста, не проходит тест в IE.В chrome, firefox все гуд

$("#header").shouldBe(Condition.visible);
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("arguments[0].style='position: absolute;'", $("#header"));

Capabilities {acceptInsecureCerts: false, browserName: internet explorer, browserVersion: 11, javascriptEnabled: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:ieOptions: {browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover: true, ie.browserCommandLineSwitches: , ie.ensureCleanSession: false, ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false, ignoreProtectedModeSettings: false, ignoreZoomSetting: false, initialBrowserUrl: http://localhost:43036/, nativeEvents: true, requireWindowFocus: false}, setWindowRect: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: adf24828-db7e-4bcd-b80f-ed86717c031e

Element not found {#header}
Expected: visible

пробовал уже искать и через класс, id, tagname всеравно в IE падает

Смотрите, вообще-то ошибка говорит что он должен быть видимым… Т.е. он его нашел, но почему-то думает что он скрыт. А это несколько другая проблема. Давайте полное сообщение об ошибке и стектрейс. Так же лучше приостановить тест и посмотреть в браузере что с этим элементом. Так же, этих элементов может быть несколько и в разных браузерах у них порядок нахождения может измениться.

Element not found {#header}
Expected: visible

Timeout: 5 s.
Caused by: NoSuchWindowException: Currently focused window has been closed.
	at com.codeborne.selenide.impl.WebElementSource.createElementNotFoundError(WebElementSource.java:34)
	at com.codeborne.selenide.impl.ElementFinder.createElementNotFoundError(ElementFinder.java:100)
	at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:62)
	at com.codeborne.selenide.commands.Should.should(Should.java:35)
	at com.codeborne.selenide.commands.Should.execute(Should.java:29)
	at com.codeborne.selenide.commands.Should.execute(Should.java:12)
	at com.codeborne.selenide.commands.Commands.execute(Commands.java:144)
	at com.codeborne.selenide.impl.SelenideElementProxy.dispatchAndRetry(SelenideElementProxy.java:99)
	at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:65)
	at com.sun.proxy.$Proxy17.shouldBe(Unknown Source)
	at objects.components.Helper.takeScreenshot(Helper.java:67)
	at tests.form1.correspondsTest(Test1.java:266)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
	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:648)
	at org.testng.TestRunner.run(TestRunner.java:505)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
	at org.testng.TestNG.runSuites(TestNG.java:1049)
	at org.testng.TestNG.run(TestNG.java:1017)
	at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73)
	at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: org.openqa.selenium.NoSuchWindowException: Currently focused window has been closed.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'BIGPC-NF322', ip: '169.254.18.196', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '9.0.1'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities {acceptInsecureCerts: false, browserName: internet explorer, browserVersion: 11, javascriptEnabled: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:ieOptions: {browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover: true, ie.browserCommandLineSwitches: , ie.ensureCleanSession: false, ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false, ignoreProtectedModeSettings: false, ignoreZoomSetting: false, initialBrowserUrl: http://localhost:43036/, nativeEvents: true, requireWindowFocus: false}, setWindowRect: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: adf24828-db7e-4bcd-b80f-ed86717c031e
*** Element info: {Using=css selector, value=#header}
	at jdk.internal.reflect.GeneratedConstructorAccessor14.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:322)
	at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:416)
	at org.openqa.selenium.By$ByCssSelector.findElement(By.java:431)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:314)
	at com.codeborne.selenide.impl.WebElementSelector.findElement(WebElementSelector.java:28)
	at com.codeborne.selenide.impl.ElementFinder.getWebElement(ElementFinder.java:74)
	at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:47)
	... 33 more

Елемент отображается в браузере, пробовал ставить задержку даже . В dom если искать #header то находит 1 элемент

ну так он может быть закрыт другим элементом с точки зрения селениума

Да не закрыт он . Если б был закрыт, то и в хроме и мозилле тест не проходил бы

Не стоит думать что если тест проходит в ff and chrome то все так же должно быть в IE.

Вот небольшой кейс с которым столкнулся на текущем проекте.

    @Override
    public void uploadFile(File file) {
        if (isChrome() == true){
            loadFile.uploadFile(file);
        }else {
            executeJavaScript("document.getElementById(\"file-upload\").style.display = \"block\";");
            getLoadFile().uploadFile(file);
            executeJavaScript("document.getElementById(\"file-upload\").style.display = \"\";");
        }
    }

Смысл этого кейса в том что в FF тэг имел style.display = " " и при попытке загрузить через input файл тест падал т.к не видел input и вроде бы кажется зачем этот костыль с js ведь это же баг, но нет это хвалёный react так устроен и для ff пришлось сделать такой ход.

В вашем случае я бы попробовал поюзать getPageSource если вы тоже используете selenide и посмотреть что там творится.
Так же сталкивался с похожими кейсами для IE и решением было сменить метод поиска с Css или xpath на ID, так и не понял почему это работало.

Решил проблему :slightly_smiling_face:

  • For IE 11 only , you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE . For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE . Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.