Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node

前端 未结 1 1941
星月不相逢
星月不相逢 2021-01-27 10:30

I have a dialog box appearing on my page every time I open it. I want to close it so that I can proceed with my programming. The dialogue box is like this image

I trie

相关标签:
1条回答
  • 2021-01-27 11:13

    It seems you were pretty close. To close the dialog box appearing on your page you need to click on the element marked as X which is a <a> tag. So to invoke click() on the desired element you need to wait for the desired element to be clickable as follows:

    • Code Block:

      System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.landrover.co.uk");
      new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.linkText("X"))).click();
      System.out.println(driver.getTitle());
      
    • Console Output:

      Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 15398
      Only local connections are allowed.
      Jun 18, 2018 2:52:08 PM org.openqa.selenium.remote.ProtocolHandshake createSession
      INFO: Detected dialect: OSS
      Premium 4x4 Vehicles & Luxury SUVs - Land Rover UK
      
    • Browser Snapshot:

    0 讨论(0)
提交回复
热议问题