I know that some selenium capabilities can be obtained with a method, one of them like this :
driver.getCapabilities().getBrowserName();
It returns the value of the browser name.
But if it refers to an available method, if I don't misunderstand it, this seems to be related to custom capabilities, like this I mean :
driver.getCapabilities().getCapability("something ?");
Returns: The value, or null if not set.
So, I've tried to make a simple code to get the value I mean.
private RemoteWebDriver driver;
private URL url;
private DesiredCapabilities dc = new DesiredCapabilities();
@Before
public void setUp() throws MalformedURLException {
url = new URL("http://localhost:4444/wd/hub");
dc.setCapability(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
//this is custom capability i mean
dc.setCapability("testName", "Login");
driver = new RemoteWebDriver(url, dc);
}
@Test
public void test() {
some code.....
}
@After
public void tearDown() {
System.out.println("Browser Name : "+ driver.getCapabilities().getCapability("browserName"));
System.out.println("Test Name : "+ driver.getCapabilities().getCapability("testName"));
driver.quit();
}
With json
, server log say :
Capabilities are: {
"browserName": "chrome",
"testName": "Login"
}
But i get a null
value.
How to the right setup ? How do you make our server provide the capabilities testName
I mean? and can be obtained with driver.getCapabilities().getCapability("testName");
Current result Browser Name : chrome
Test Name : null
Expected result Browser Name : chrome
Test Name : Login
Thanks advance
.getCapability("browserName")
platformName
etc, it will return a value, but it still the default available in selenium. I've used a paid testing platform (platform based on selenium and appium) and for the purposes of the report name I can only setup by adding thedc.setCapability("testName"," Login ")
method, and I can get the value oftestName
using the method.getCapability ("testName")
, even I can also get the value of the report url using the.getCapability ("urlReport")
method. So I assume that the name of the capability can be custom as needed. – Oriental