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,820 points

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
0 votes
1 answer

What is the actual conflict while performing click() on web element, and getting an error like element is not clickable at point(x,y)?

Hey @sastry, the error Element is not clickable ...READ MORE

answered Nov 27, 2019 in Selenium by Sirajul
• 59,090 points
0 votes
1 answer

Getting error while run the selenium scripts.How can i resolve this issue?

Tq. Yes, it worked for me. READ MORE

answered Jun 16, 2020 in Selenium by anonymous
0 votes
2 answers

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,500 points
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
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,890 points
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
+1 vote
1 answer