selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🐛 Bug]: Cannot create a new session selenium grid 4.3.0

Open sudo-naim opened this issue 4 years ago • 4 comments

What happened?

Router is returning http.status_code = 500 when trying to create a new session. I am using the WebDriverManager library from io.github.bonigarcia.wdm.WebDriverManager Commands used to start up grid 4 in distributed mode:

java -jar selenium-server-4.3.0.jar event-bus
java -jar selenium-server-4.3.0.jar sessions
java -jar selenium-server-4.3.0.jar sessionsqueue
java -jar selenium-server-4.3.0.jar distributor --sessions http://localhost:5556 --sessionqueue http://localhost:5559 --bind-bus false
java -jar selenium-server-4.3.0.jar router --sessions http://localhost:5556 --distributor http://localhost:5553 --sessionqueue http://localhost:5559
java -jar selenium-server-4.3.0.jar node --config config.toml

My project code:

import io.github.bonigarcia.wdm.WebDriverManager;
import org.example.Main;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Optional;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;

public class test1 {

    RemoteWebDriver remoteDriver;
    static String driverPath;
    private static String timeout = "idleTimeout";
    @BeforeSuite
    public void setUpBeforeSuite(@Optional("mac") String os)  {


        WebDriverManager wdm = WebDriverManager.edgedriver();
        wdm.setup();
        driverPath = wdm.getDownloadedDriverPath();

    }

    @BeforeMethod
    public synchronized void createDriverInstance(){
        remoteDriver = new RemoteWebDriver(createGridRemoteAddress("http://localhost:4444"), createEdgeOptions());
    }

    @Test
    public void testMethod(){

        remoteDriver.manage().window().maximize();
    }

    public static EdgeOptions createEdgeOptions() {
        EdgeOptions options = new EdgeOptions();
        options.setCapability("browserName", "MicrosoftEdge");
        options.setCapability("screenResolution", "1920x1080");
        options.setCapability("platformName", "mac");
        options.setCapability("excludeSwitches", "enable-logging");
        options.setCapability(timeout, 720);
        return options;
    }

    private URL createGridRemoteAddress(String gridUrl) {
        URL remoteAddress = null;
        try {
            remoteAddress = new URL(gridUrl);
        }
        catch (MalformedURLException e) {
            System.out.println("Selenium Grid address is malformed");
            Assert.fail("Selenium Grid address is malformed", e);
        }
        return remoteAddress;
    }
}


Additionally i tried using this but no luck i got the same result: WebDriverManager.edgedriver().remoteAddress("http://localhost:4444").create();

How can we reproduce the issue?

Commands used to start up grid 4 in distributed mode:

java -jar selenium-server-4.3.0.jar event-bus
java -jar selenium-server-4.3.0.jar sessions
java -jar selenium-server-4.3.0.jar sessionsqueue
java -jar selenium-server-4.3.0.jar distributor --sessions http://localhost:5556 --sessionqueue http://localhost:5559 --bind-bus false
java -jar selenium-server-4.3.0.jar router --sessions http://localhost:5556 --distributor http://localhost:5553 --sessionqueue http://localhost:5559
java -jar selenium-server-4.3.0.jar node --config config.toml

Relevant log output

Distributer Log:

INFO [LocalDistributor.newSession] - Session request received by the Distributor:
 [Capabilities {browserName: MicrosoftEdge, excludeSwitches: enable-logging, screenResolution: 1920x1080}, Capabilities {browserName: MicrosoftEdge}]

Router Log:

WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "9ac645dd7ea77e9bad5f8291c68f9789","eventTime": 1660660487798051667,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.sessionqueue.remote.RemoteNewSessionQueue","http.host": "localhost:4444","http.method": "POST","http.request_content_length": "253","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession","http.user_agent": "selenium\u002f3.141.59 (java mac)"}}

IntelliJ log output

Could not start a new session. Response code 500. Message: Could not start a new session. Could not start a new session. Could not start a new session. The path to the driver executable The path to the driver executable must be set by the webdriver.edge.driver system property; for more information, see https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/. The latest version can be downloaded from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'KJK4GV4T9N', ip: '2003:cf:1f10:a300:5c77:74aa:2220:3d07%en0', os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.5', java.version: '15.0.8'
Driver info: driver.version: unknown
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'KJK4GV4T9N', ip: 'fe80:0:0:0:4bc:f1e5:5dc1:e36f%en0', os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.5', java.version: '15.0.8'
Driver info: driver.version: unknown
Build info: version: '4.4.0', revision: 'e5c75ed026a'
System info: host: 'KJK4GV4T9N', ip: '2003:cf:1f10:a300:5c77:74aa:2220:3d07%en0', os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.5', java.version: '15.0.8'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: MicrosoftEdge, excludeSwitches: enable-logging, idleTimeout: 720, ms:edgeOptions: {args: [], extensions: []}, platformName: MAC, screenResolution: 1920x1080}], desiredCapabilities=Capabilities {browserName: MicrosoftEdge, excludeSwitches: enable-logging, idleTimeout: 720, ms:edgeOptions: {args: [], extensions: []}, platformName: MAC, screenResolution: 1920x1080}}]
Capabilities {}
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Could not start a new session. Could not start a new session. Could not start a new session. The path to the driver executable The path to the driver executable must be set by the webdriver.edge.driver system property; for more information, see https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/. The latest version can be downloaded from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'KJK4GV4T9N', ip: '2003:cf:1f10:a300:5c77:74aa:2220:3d07%en0', os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.5', java.version: '15.0.8'
Driver info: driver.version: unknown
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'KJK4GV4T9N', ip: 'fe80:0:0:0:4bc:f1e5:5dc1:e36f%en0', os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.5', java.version: '15.0.8'
Driver info: driver.version: unknown
Build info: version: '4.4.0', revision: 'e5c75ed026a'
System info: host: 'KJK4GV4T9N', ip: '2003:cf:1f10:a300:5c77:74aa:2220:3d07%en0', os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.5', java.version: '15.0.8'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: MicrosoftEdge, excludeSwitches: enable-logging, idleTimeout: 720, ms:edgeOptions: {args: [], extensions: []}, platformName: MAC, screenResolution: 1920x1080}], desiredCapabilities=Capabilities {browserName: MicrosoftEdge, excludeSwitches: enable-logging, idleTimeout: 720, ms:edgeOptions: {args: [], extensions: []}, platformName: MAC, screenResolution: 1920x1080}}]
Capabilities {}


### Operating System

macOS (M1)

### Selenium version

4.4.0

### What are the browser(s) and version(s) where you see this issue?

Edge. Using the WebDriverManager

### What are the browser driver(s) and version(s) where you see this issue?

Edge. Using the WebDriverManager

### Are you using Selenium Grid?

4.3.0

sudo-naim avatar Aug 16 '22 21:08 sudo-naim

@Naim995, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar Aug 16 '22 21:08 github-actions[bot]

Thank you for sharing the details. When calling java -jar selenium-server-4.3.0.jar node --config config.toml, what does the config.toml contain? What do the node logs look like? As the error message states, the issue is with the Webdriver path. I suggest please double check the Grid logs to see that edge is added. Also, the code snippet shared uses driverPath which is not used and also not relevant when using the Grid since the node picks up the webdriver on your system path unless that is disabled. This seems more of a setup issue and not a bug.

pujagani avatar Aug 17 '22 04:08 pujagani

@pujagani is right. This is a configuration issue. msedgedriver needs to be in the path. WebDriverManager configures the driver for your tests but not for Grid.

If you want to use it for Grid, check their docs https://bonigarcia.dev/webdrivermanager/#selenium-grid

diemol avatar Aug 17 '22 07:08 diemol

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Sep 17 '22 00:09 github-actions[bot]