Search code examples
javaseleniumselenium-webdrivermarionette

After switching WebDriver to alert Marionette stops working


Here is a snippet of my code:

public void deleteOffer(){
        driver.findElement(By.xpath("html/body/main/div/div/div/div[2]/a[2]")).click();
        driver.switchTo().alert().accept();
        driver.findElement(By.xpath("html/body/div[1]/div")).click();
    }

Im getting this error: 1494803297020 Marionette INFO New connections will no longer be accepted

It seems like it's stopping working right after driver.switchTo().alert().accept(); so I guess the reason is that I shoul switch back to main frame but I don't know how to do it. I have tried driver.switchTo().parentFrame(); and driver.switchTo().defaultContent(); but getting still the same error.


Solution

  • Here is the solution to your Question:

    I don't see any error as such in your code, but I will suggest the following:

    1. Before you switch to Alert to Accept, slow down a bit, induce some wait.
    2. If you are using driver.switchTo().alert().accept() then you don't need to switch back to the main frame.
    3. When you are trying to find out some element on the main page by driver.findElement(By.xpath("html/body/div[1]/div")).click();,slow down a bit, induce some wait again.
    4. The error you see New connections will no longer be accepted is something serious Marionette complaining about which essentially means you are trying a test step which can't be achieved by the geckodriver. Hence you may need to change your code for the geckodriver to proceed with the task.
    5. Finally, both of your xpath looks petty vulnerable to me. Instead of using absolute xpath you should try to use logical unique xpath.

    Let me know if this Answers your Question.