Skip to content

[πŸ› Bug]: Unable to trigger the Test with specific Browser version in Selenium GridΒ #14788

@arunkumarr88

Description

@arunkumarr88

What happened?

Im using selenium 4.26 with openJdk 11.0.2. I have a selenium grid with 10 machines. When i try to run the test with specific browser version, the tests goes in queue and fails.

Refer below grid ui image where thetest goes in queue.
image

How can we reproduce the issue?

public RemoteWebDriver startGrid(String browser) throws Exception {
		log.info("Going to setup grid...");
		int resolutionWidth;
		int resolutionHeight;
		String[] resolution = ReadPropertyFile.getInstance().getPropertyValue("resolution").split(",");
		String headlessFlag = ReadPropertyFile.getInstance().getPropertyValue("headlessFlag");
		resolutionWidth = Integer.parseInt(resolution[0]);
		resolutionHeight = Integer.parseInt(resolution[1]);
		MutableCapabilities cap = new MutableCapabilities();
		cap.setCapability("platformName", "ANY");
		if (browser.equalsIgnoreCase(BrowserConstants.CHROME_BROWSER)) {
			cap.setCapability("browserName", BrowserConstants.CHROME_BROWSER);
			ChromeOptions options = new ChromeOptions();
			**options.setBrowserVersion(ReadPropertyFile.getInstance()
	    	        .getPropertyValue("browserVersion"));**
			if (headlessFlag.equalsIgnoreCase("true")) {
				options.addArguments("--headless=new");
			}
			options.addArguments("--incognito");
			Map<String, Object> profile = new HashMap<>();
			Map<String, Object> prefs = new HashMap<>();
			prefs.put("profile", profile);
			prefs.put("credentials_enable_service", false);
			prefs.put("profile.password_manager_enabled", false);			
			options.setExperimentalOption("prefs", prefs);
			options.addArguments("--ignore-ssl-errors=yes");
			options.addArguments("--ignore-certificate-errors");
			options.addArguments("--disable-search-engine-choice-screen");
			options.addArguments("--disable-features=OptimizationGuideModelDownloading,OptimizationHintsFetching,OptimizationTargetPrediction,OptimizationHints");			
			options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
			options.setExperimentalOption("useAutomationExtension", false);
			options.setCapability("se:name", getTestcaseName());
			options = options.merge(cap);
			log.info("Going to get Driver instance from thread local class...");
			
			RemoteCustomDriver.getInstance().setRemotedriver(new RemoteWebDriver(new URL(getHubUrl()), options));			 
			SessionId sessionId = (RemoteCustomDriver.getInstance().getRemotedriver()).getSessionId();

			nodeIp = getNodeIp(sessionId);
			RemoteCustomDriver.getInstance().getRemotedriver().manage().deleteAllCookies();
			RemoteCustomDriver.getInstance().getRemotedriver().navigate().to(getUrl());
		} else if (browser.equalsIgnoreCase(BrowserConstants.FIREFOX_BROWSER)) {
			cap.setCapability("browserName", BrowserConstants.FIREFOX_BROWSER);
			FirefoxOptions options = new FirefoxOptions();
			**options.setBrowserVersion(ReadPropertyFile.getInstance()
	    	        .getPropertyValue("browserVersion"));**
			if (headlessFlag.equalsIgnoreCase("true")) {
				options.addArguments("--headless=new");
			}
			options.addArguments("-private");
			options.merge(cap);
			log.info("Going to get Driver instance from thread local class...");
			RemoteCustomDriver.getInstance().setRemotedriver(new RemoteWebDriver(new URL(getHubUrl()), options));
			RemoteCustomDriver.getInstance().getRemotedriver().manage().deleteAllCookies();
			RemoteCustomDriver.getInstance().getRemotedriver().navigate().to(getUrl());
		} else if (browser.equalsIgnoreCase(BrowserConstants.EDGE_BROWSER)) {
			cap.setCapability("browserName", BrowserConstants.EDGE_BROWSER);
			EdgeOptions options = new EdgeOptions();
			**options.setBrowserVersion(ReadPropertyFile.getInstance()
	    	        .getPropertyValue("browserVersion"));**
			if (headlessFlag.equalsIgnoreCase("true")) {
				options.addArguments("--headless=new");
			}
			options.addArguments("--ignore-ssl-errors=yes");
			options.addArguments("--ignore-certificate-errors");
			options.addArguments("--disable-search-engine-choice-screen");
			options.addArguments("--disable-features=OptimizationGuideModelDownloading,OptimizationHintsFetching,OptimizationTargetPrediction,OptimizationHints");	
			options.merge(cap);
			log.info("Going to get Driver instance from thread local class...");
			RemoteCustomDriver.getInstance().setRemotedriver(new RemoteWebDriver(new URL(getHubUrl()), options));
			SessionId sessionId = (RemoteCustomDriver.getInstance().getRemotedriver()).getSessionId();

			nodeIp = getNodeIp(sessionId);
			RemoteCustomDriver.getInstance().getRemotedriver().manage().deleteAllCookies();
			RemoteCustomDriver.getInstance().getRemotedriver().navigate().to(getUrl());
		} 
		RemoteCustomDriver.getInstance().getRemotedriver().navigate().refresh();
		RemoteCustomDriver.getInstance().getRemotedriver().manage().window()
				.setSize(new Dimension(resolutionWidth, resolutionHeight));
		RemoteCustomDriver.getInstance().getRemotedriver().manage().timeouts().pageLoadTimeout(Duration.ofSeconds(30));
		RemoteCustomDriver.getInstance().getRemotedriver().manage().timeouts().scriptTimeout(Duration.ofMinutes(2));
		RemoteCustomDriver.getInstance().getRemotedriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
		String version = RemoteCustomDriver.getInstance().getRemotedriver().getCapabilities().toString();
		System.setProperty("Browser/Driver Versions", version);
		return RemoteCustomDriver.getInstance().getRemotedriver();
	}

Below are the commands that i'm using to start the server.
**For Hub :**   java -jar selenium-server-4.26.0.jar hub --session-request-timeout 1300  --log-level "info" --log C:\Selenium4.23GridHub\hublog.log
**For Node :**  java -jar selenium-server-4.26.0.jar node --session-timeout 1000 --max-sessions 4 --selenium-manager true --detect-drivers true --publish-events tcp://10.50.12.39:4442 --subscribe-events tcp://10.50.12.39:4443 --log-level "info" --log C:\Selenium4.23GridNode\nodelog.log

Relevant log output

Session Not Created due to: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: 'PRONVDC048', ip: '192.168.64.145'

Operating System

Windows 10

Selenium version

4.26

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

130

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

130

Are you using Selenium Grid?

4.26

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-gridEverything grid and server relatedI-defectSomething is not working as intendedJ-awaiting answerQuestion asked of user; a reply moves it to triage againJ-issue-templateApplied to issues not following the template, or missing information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions