Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (47.6k points)

How do I locate After and Before css tag in selenium webdriver?

1 Answer

0 votes
by (106k points)

Actually this can not be done by using any of the WebDriver locator strategies like XPATH, CSS etc. We can only use this using Javascript.

Here is the sample code in Java:- 

WebElement switchLabel = driver.findElement(By.cssSelector(“.className”));

String colorRGB = ((JavascriptExecutor)driver)

       .executeScript("return window.getComputedStyle(arguments[0], ':before').

If you want to learn Selenium then you must take up the following Selenium online training. You can also read the following Selenium tutorial.

Java Video:

Selenium Video:

Browse Categories

...