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:

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.5k questions

29.9k answers

500 comments

99.1k users

Browse Categories

...