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