How to get the color code of dropdown text with Selenium WebDriver ?
Solution :
Lets first create the instance of WebDriver :
Next, we will open the url and find the WebElement i.e dropdown.
by using "selectByVisibleText()" method.
Solution :
Lets first create the instance of WebDriver :
WebDriver driver; System.setProperty("webdriver.chrome.driver", "C:/Users/User/Downloads/chromedriver/chromedriver.exe"); driver = new ChromeDriver();
Next, we will open the url and find the WebElement i.e dropdown.
driver.get("file:///C:/Users/User/Desktop/Blog/ColorText.html"); WebElement dropDown = driver.findElement(By.cssSelector("select[class='selectDiv']"));Now, create the instance of "Select" class and click on the option "Audi" from dropdown
by using "selectByVisibleText()" method.
Select select = new Select(dropDown); select.selectByVisibleText("Audi");Now, we will get the selected option color code and by using "Color" class of java we will convert the rgb color code to hex color code.
String colorValue = select.getFirstSelectedOption().getCssValue("color"); String hexColorCode = Color.fromString(colorValue).asHex(); System.out.println("Selected Option color code is " + hexColorCode );Hope you like this post. Thanks
Selenium IDE, or Selenium Integrated Development Environment is a handy software testing tool, prepared by Apache Software Foundation. Pronounced as the one of the fastest and easiest testing frameworks,
ReplyDeleteSelenium Automation Training London
After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
ReplyDeleteThank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in
Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune