dawge4qd
dawge4qd

Reputation: 11

Could not start a new session. Response code 500. Message: session not created using Selenium Java with a downloaded chromedriver

When I try to start a new Microsoft Edge session, I encounter this error:

Unknown Problem: Could not start a new session. Response code 500. Message: session not created from no such execution context: loader has changed while resolving nodes (Session info: MicrosoftEdge=114.0.1823.79) System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.15' Driver info: org.openqa.selenium.edge.EdgeDriver

I have already researched this specific error, and the only solution I found was to add these two arguments:

--disable-dev-shm-usage --remote-allow-origins=*

and to add this setting:

System.setProperty("webdriver.edge.driver", "driverpath");

which I have already done.

Edit: This problem only occurs in our CI, and it happens kind of randomly.

Upvotes: 0

Views: 3008

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193108

You need to consider a couple of things:

  • Upgrade to Selenium v4.6 or above so Selenium Manager can automatically download the matching EdgeDriver. So you can remove

    System.setProperty("webdriver.edge.driver", "driverpath");
    
  • --remote-allow-origins=* is no more mandatory with Chrome and ChromeDriver version: 114.0. So you can drop it.

  • disable-dev-shm-usage isn't effective unless you are using the --no-sandbox argument. So you can drop it.

Making the above mentioned adjustments execute your code.

Upvotes: 1

Yaroslavm
Yaroslavm

Reputation: 4804

If you're wanting to handle drivers version / installation automatically, I suggest to use Webdriver manager like this

You can simply add dependency to pom.xml

        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>5.3.2</version>
        </dependency>

Reference

And then use code like

public class SiteTest extends BaseTest {

    @BeforeClass
    public static void setupAll() {
        WebDriverManager.edgedriver().setup();
    }

    @Test
    public void openSite() {
        WebDriver driver = new EdgeDriver();
        driver.get("https://example.com");
    }
}

If this would work for you - so issue with session was in driver compatibility.

Upvotes: 1

Related Questions