Getting error while inspecting the search box in google.

0 votes

When I am trying to use ClassName for locating the search box in google I am getting this error:

org.openqa.selenium.InvalidSelectorException: invalid selector: Compound class names not permitted
  (Session info: chrome=71.0.3578.98)

Can someone help please?

I am using the following statement:

driver.findElement(By.className("gLFyf gsfi")).sendKeys("Hello world");}

Dec 21, 2018 in Selenium by Jino
• 5,560 points
130 views

1 answer to this question.

0 votes

By looking at your error it seems that there are multiple class with the same name and selenium cannot locate it using ClassName. 

Its better you try it using ID , Xpath or CSS Selector.

I used CSS Selector and it worked fine:

driver.findElement(By.cssSelector("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input")).sendKeys("Hello World");

Hope it was of help.

answered Dec 21, 2018 by Nabarupa

Related Questions In Selenium

+4 votes
1 answer
0 votes
1 answer

Getting error while running a XML file in TestNG

Hello @Sradha, The synatx of using test is ...READ MORE

answered Dec 26, 2018 in Selenium by Rashmi
455 views
0 votes
1 answer
0 votes
2 answers

Getting Error in System.setProperty of ChromeDriver

System.setProperty("webdriver.chrome.driver", ...READ MORE

answered Jan 8 in Selenium by anonymous
1,937 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
405 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
761 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
401 views
+1 vote
1 answer