Closed sabbir-aust closed 2 years ago
If it is working for Chrome but not the others then you are definitely not sending the capability. However, please share a complete code sample I can use to reproduce the issue.
If it is working for Chrome but not the others then you are definitely not sending the capability. However, please share a complete code sample I can use to reproduce the issue.
Here's the capability: @diemol
@Parameters({"mobileOrDesktop", "deviceName", "shop", "environment", "browser"}) public void setUp(ITestContext ctx, String mobileOrDesktop, String deviceName, String shop, String environment, String browser) throws MalformedURLException, InterruptedException {
String loginUserName;
String loginPassword;
propertyReader = new PropertyReader();
String applicationUrl = "";
String host = "localhost";
DesiredCapabilities dc = new DesiredCapabilities();
String browsers = browser;
if (browsers.equalsIgnoreCase("firefox")) {
//dc = DesiredCapabilities.firefox();
FirefoxOptions firefoxOptions= new FirefoxOptions();
dc.setBrowserName(browsers);
firefoxOptions.setCapability("se:recordVideo", true);
firefoxOptions.merge(dc);
driver = new RemoteWebDriver(new URL("http://localhost:4444/"),dc);
}
else if((browsers.equalsIgnoreCase("MicrosoftEdge"))){
EdgeOptions edgeOptions = new EdgeOptions();
dc.setBrowserName(browsers);
edgeOptions.setCapability("se:recordVideo", true);
edgeOptions.merge(dc);
driver = new RemoteWebDriver(new URL("http://localhost:4444/"),dc);
}
else if (browsers.equalsIgnoreCase("chrome")) {
ChromeOptions chromeOptions = new ChromeOptions();
if (mobileOrDesktop.equalsIgnoreCase("Mobile")) {
HashMap<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName",deviceName);
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
chromeOptions.setCapability("se:recordVideo", true);
dc.setCapability(ChromeOptions.CAPABILITY,chromeOptions);
}else{
dc.setBrowserName(browsers);
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.setCapability("se:recordVideo", true);
chromeOptions.merge(dc);
}
driver = new RemoteWebDriver(new URL("http://localhost:4444/"),chromeOptions);
}
String testName = ctx.getCurrentXmlTest().getName();
dc.setCapability("name", testName);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);
}
Here's the xml file:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
For example, String browsers = browser;
, where does browser
come from?
I cannot copy & paste that to my IDE because there are missing values. I do not know how to use that XML file. Can you please share a single method with all the values already there so I can reproduce the issue? I cannot troubleshoot that code.
Use this browser capability method in any of your selenium test. @diemol
public void setUp() throws MalformedURLException, InterruptedException {
String loginUserName; String loginPassword; String applicationUrl = ""; String host = "localhost"; DesiredCapabilities dc = new DesiredCapabilities(); String browsers = MicrosoftEdge; if (browsers.equalsIgnoreCase("firefox")) { //dc = DesiredCapabilities.firefox(); FirefoxOptions firefoxOptions= new FirefoxOptions(); dc.setBrowserName(browsers); firefoxOptions.setCapability("se:recordVideo", true); firefoxOptions.merge(dc); driver = new RemoteWebDriver(new URL("http://localhost:4444/"),dc); } else if((browsers.equalsIgnoreCase("MicrosoftEdge"))){ EdgeOptions edgeOptions = new EdgeOptions(); dc.setBrowserName(browsers); edgeOptions.setCapability("se:recordVideo", true); edgeOptions.merge(dc); driver = new RemoteWebDriver(new URL("http://localhost:4444/"),dc); } else if (browsers.equalsIgnoreCase("chrome")) { ChromeOptions chromeOptions = new ChromeOptions(); dc.setBrowserName(browsers); chromeOptions.addArguments("--disable-dev-shm-usage"); chromeOptions.setCapability("se:recordVideo", true); chromeOptions.merge(dc); driver = new RemoteWebDriver(new URL("http://localhost:4444/"),chromeOptions); } String testName = Test; dc.setCapability("name", testName); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS); }
Hi @diemol , I've added the firefoxoptions and edgeoption to the driver and it's now working. Now it's recording video for all the browser. Now i want to save the video folder with the test name instead of session id. For that i have used this line: chromeOptions.setCapability("se:name", testName); in to the browser parameter. It's showing the test name on to the selenium grid session running page but in my project folder it's saving the folder with the session id.
Here's the browser capability code:
public void setUp() throws MalformedURLException, InterruptedException { DesiredCapabilities dc = new DesiredCapabilities(); String testName = "Demo Test"; String browsers = chrome;
if (browsers.equalsIgnoreCase("chrome")) { ChromeOptions chromeOptions = new ChromeOptions(); dc.setBrowserName(browsers); chromeOptions.addArguments("--disable-dev-shm-usage"); chromeOptions.setCapability("se:recordVideo", true); chromeOptions.setCapability("se:name", testName); chromeOptions.merge(dc); driver = new RemoteWebDriver(new URL("http://localhost:4444/"),chromeOptions); } }
Here's the screenshots: https://prnt.sc/bPXNNBVd8-Gy https://prnt.sc/YafWxOEHgsbP
It is not possible. The test name information will be saved into the capabilities file that is saved. From the you could grab de information and potentially have a dashboard.
I'll close this issue as the initial motivation was not a bug but the capabilities were not being sent correctly.
It is not possible. The test name information will be saved into the capabilities file that is saved. From the you could grab de information and potentially have a dashboard.
I'll close this issue as the initial motivation was not a bug but the capabilities were not being sent correctly.
@diemol can you please provide some resource or any suggestions on how i can grab the information from the json file and create a dashboard??
I don't have anything concrete. My comment is more generic where anyone who is interested in that information needs to build a dashboard from scratch.
What happened?
I've copy pasted the exact same code of both the config.toml file and dynamic grid compose file. Then i've run the "docker compose up" command and run a test. According to the configuration, under my project the test recording video for all the browser type should be available along with a "sessionCapabilities.json" file. But it's saving only video for chrome browser. Not the edge and firefox. The scripts are successfully running on all of the browsers. I've also added the capabilities for different browser like this: Firefox: firefoxOptions.setCapability("se:recordVideo", true); Edge: edgeOptions.setCapability("se:recordVideo", true); chrome: chromeOptions.setCapability("se:recordVideo", true);
Command used to start Selenium Grid with Docker
Relevant log output
Operating System
Windows 10
Docker Selenium version (tag)
4.3.0-20220628