Getting error while inspecting the search box in google.

+1 vote

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,570 points
194 views

1 answer to this question.

+1 vote

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

I also tried with Class Name, getting same error. And there is only 1 class with this name.

Hey, could you share the code snippet (the div part that contains the class name) for a better understanding of the issue that you are facing?

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
1,232 views
0 votes
1 answer
0 votes
1 answer
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,430 points
1,193 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,510 points
1,278 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,510 points
1,036 views
+1 vote
1 answer