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 in Selenium by anonymous
• 120 points

edited Sep 18 by Omkar 885 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 by Abha
• 27,200 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
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,280 points
712 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,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
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 in Selenium by Abha
• 27,200 points
515 views
0 votes
1 answer