How can I locate inline elements from a web page using Selenium Webdriver

0 votes

Below is my code:

driver.get("https://www.google.com");

driver.findElement(By.xpath("//*[@id='gbwa']/div/a")).click();

Thread.sleep(4000);

driver.findElement(By.cssSelector("#yDmH0d > c-wiz > div > div > c-wiz > div > div > ul:nth-child(3) > li:nth-child(4) > a > span.MrEfLc")).click();

While executing this code below error I got:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#yDmH0d > c-wiz > div > div > c-wiz > div > div > ul:nth-child(3) > li:nth-child(4) > a > span.MrEfLc"}

  (Session info: chrome=77.0.3865.75)

For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
Driver info: org.openqa.selenium.chrome.ChromeDriver

Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 77.0.3865.75, chrome: {chromedriverVersion: 77.0.3865.40 (f484704e052e0..., userDataDir: C:\Users\Falgu\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:56324}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}

Session ID: 10bfd87d03f811fc59fac13b1832bf08

*** Element info: {Using=css selector, value=#yDmH0d > c-wiz > div > div > c-wiz > div > div > ul:nth-child(3) > li:nth-child(4) > a > span.MrEfLc}

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)

at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)

at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)

at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)

at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:420)

at org.openqa.selenium.By$ByCssSelector.findElement(By.java:431)

at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)

at abcd.HandlingInlineElements.main(HandlingInlineElements.java:20)

I have tried Xpath as well. But it is showing error.

Sep 18, 2019 in Selenium by anonymous
• 140 points

edited Sep 18, 2019 by Omkar 4,070 views

1 answer to this question.

0 votes

Which specific element you are trying to click on google.com page? Because your element with xpath 

"//*[@id='gbwa']/div/a" 

isn't visible on the page.

answered Oct 10, 2019 by Abha
• 28,140 points

Related Questions In Selenium

0 votes
1 answer

How can I locate web elements from a web page using Selenium Webdriver?

Hey @Dushyant, Locating elements in WebDriver is ...READ MORE

answered May 29, 2019 in Selenium by Shreya
2,911 views
0 votes
1 answer

How can I scroll a web page in Mozilla Firefox using Selenium?

Hi Rohan, steps to scroll a webpage in ...READ MORE

answered May 14, 2019 in Selenium by Pratibha
• 3,690 points
3,215 views
0 votes
1 answer

How can I select an option from a dropdown using Ruby Selenium Webdriver?

Hey Swasti, you can try following lines ...READ MORE

answered Aug 26, 2019 in Selenium by Anvi
• 14,150 points
4,774 views
0 votes
1 answer

How can I download the *.jar file from http:// seleniumhq.org using selenium WebDriver?

For Selenium Standalone Server use this: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); and ...READ MORE

answered Apr 9, 2018 in Selenium by Martin
• 4,320 points
3,555 views
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
13,727 views
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
9,167 views
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,910 points
7,244 views
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
7,885 views
0 votes
1 answer

How can I select date from a datepicker div using Selenium Webdriver?

Hey Jeevika, you can use following automation ...READ MORE

answered Jul 15, 2019 in Selenium by Abha
• 28,140 points
12,191 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP