Error showing up Unable to click the second page and get title Any Solution

0 votes
import java.util.Set;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;


public class BrowserWindows {

public static void main(String[] args) {


  WebDriver driver=new ChromeDriver();


  driver.get("");  //Capture handle value

//  String handlevalue=driver.getWindowHandle();         //Store in a variable

//  System.out.println(handlevalue); //CDwindow-1A6D516C21A063C8496DFE809863B7F5

//                                  // CDwindow-8D78D9E2D94725448C8AB947F0C61251



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


  Set<String> handlevalues =driver.getWindowHandles();


  for(String h:handlevalues)  //furloop




String title=driver.switchTo().window(h).getTitle(); //after capturing window handle get title of webpage


if(title.equals("SeleniumHQ Browser Automation"));





  ------------------------------------------------Console Window----------------------------------------------------------------------------------------

Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 23296

Only local connections are allowed.

Please see for suggestions on keeping ChromeDriver safe.

ChromeDriver was started successfully.

[1606266585.911][WARNING]: This version of ChromeDriver has not been tested with Chrome version 87.

Nov 24, 2020 7:09:47 PM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Detected dialect: W3C


Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='navbar']/a[1]"}

  (Session info: chrome=87.0.4280.66)

For documentation on this error, please visit:

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'

System info: host: 'DESKTOP-D0DRPFI', ip: '', 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.1'

Driver info:

Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 87.0.4280.66, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\mailf\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:65027}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}

Session ID: fef7f1e771d40aa6492fd65b39837306

*** Element info: {Using=xpath, value=//*[@id='navbar']/a[1]}

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(

at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(

at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(

at java.base/java.lang.reflect.Constructor.newInstance(

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(

at org.openqa.selenium.remote.HttpCommandExecutor.execute(

at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(

at org.openqa.selenium.remote.RemoteWebDriver.execute(

at org.openqa.selenium.remote.RemoteWebDriver.findElement(

at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(

at org.openqa.selenium.By$ByXPath.findElement(

at org.openqa.selenium.remote.RemoteWebDriver.findElement(

at day18.BrowserWindows.main(
Nov 25, 2020 in Selenium by faha
• 360 points

1 answer to this question.

0 votes

Hi, @Faha,

As you access the URL there is an Ajax loader that blocks the UI, so we have to wait for the Ajax loader to complete loading all the WebElements and the email and password field becomes visible. To achieve that we will introduce ExplicitWait i.e. WebDriverWait with ExpectedConditions set to elementToBeClickable for the email field.

answered Nov 25, 2020 by Gitika
• 65,930 points
Ok Thanks Gitika.

Related Questions In Selenium

0 votes
1 answer
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 5, 2020 in Selenium by Sri
• 3,070 points
+1 vote
2 answers
0 votes
3 answers

How to click the search button using Selenium web driver and Python

You can try with tag. #this code will ...READ MORE

answered Apr 10, 2019 in Selenium by Matin
+1 vote
2 answers

How to get the title of a webpage using Selenium Java?

Essentially, driver.getTitle(); function can be used to ...READ MORE

answered Dec 17, 2018 in Selenium by Vardhan
• 13,190 points
0 votes
0 answers

How to get the text from the HTML5 input error message in Selenium?

On giving invalid data in the email ...READ MORE

Mar 11, 2019 in Selenium by Vaishnavi
• 1,180 points
0 votes
2 answers

Is there any way to get the text of a web element using Selenium Webdriver?

use gettext() in java : string lableText = ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,070 points
0 votes
1 answer

How to resolve this error? Element not interactable ...Any solution?

Hi, @Faha, ElementNotInteractableException: Element is not reachable by ...READ MORE

answered Nov 24, 2020 in Selenium by Gitika
• 65,930 points
0 votes
1 answer

Sikuli file upload, even after writing the correct script getting error. Any solution?

Hey, @Faha, This error message... JavaScript error: resource://gre/modules/XULStore.jsm, line ...READ MORE

answered Dec 15, 2020 in Selenium by Gitika
• 65,930 points