I'm working on this site. There is a Next button. I want to click it using CSS selector only.
I'm using below code to get the element:
driver.findElement(By.cssSelector("span.RveJvd.snByac"))
span.RveJvd.snByac
is also used for Forgot email? button so this one is getting clicked.
Is there a way to combine class and the text 'Next' attributes of Next button?
Note : I have to use only CSS selector.
1 Answer 1
Css selectors do not allow selecting by inner text. To click that button with css you can just use:
driver.findElement(By.cssSelector("#identifierNext"))
or
driver.findElement(By.cssSelector("#identifierNext span"))
-
Hi thanks, it worked. Can you tell me difference between above two lines of code? In which case addition of tag (span) is helpful?rushi– rushi2018年09月20日 02:04:07 +00:00Commented Sep 20, 2018 at 2:04
-
It depends on which element does actually have the action assigned. In other words which element actually represents a button.Alexey R.– Alexey R.2018年09月20日 07:28:23 +00:00Commented Sep 20, 2018 at 7:28
Explore related questions
See similar questions with these tags.