由于Chatbot切换硒,ElementNotInteractable异常

时间:2020-08-11 15:47:03

标签: javascript java selenium exception

我们最近在我们的网站中集成了一个聊天机器人应用程序,它没有最小化或关闭按钮。登录后,它将在所有页面中重叠。因此,因此登录后,一旦尝试单击任何元素,就会引发错误,因为元素不可交互。有没有什么办法可以解决此问题,例如使用JavaScript禁用此功能? enter image description here

我试图使用javascript隐藏聊天标志,并尝试仍然执行操作。这是抛出元素Not notableable错误。

WebElement chatPill = driver.findElement(By.cssSelector("div[id='fc_frame']"));
        System.out.println("execution started");
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("arguments[0].setAttribute('style','display:none')",chatPill);
//        js.executeScript("arguments[0].setAttribute('style','z-index:-100')",chatPill);
        System.out.println("Script execution Completed - chat box Hidden");
  wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[contains(@class,'sidebar-menu')]/a[text()='Employees']")));

    
    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[text()='Reports']")));
    driver.findElement(By.xpath("//a[text()='Reports']")).click();

控制台日志:

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: element not interactable
  (Session info: chrome=84.0.4147.105)
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:19.891Z'
System info: host: 'LetsVentures-MacBook-Pro.local', ip: '192.168.29.225', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.5', java.version: '11.0.5'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 84.0.4147.105, chrome: {chromedriverVersion: 84.0.4147.30 (48b3e868b4cc0..., userDataDir: /var/folders/vd/4xltw6c51_j...}, goog:chromeOptions: {debuggerAddress: localhost:59011}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: 34e18768d41e130605a9cd5ef800ac71
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    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.RemoteWebElement.execute(RemoteWebElement.java:276)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
    at resources.chatBoxHiding.main(chatBoxHiding.java:41)

0 个答案:

没有答案