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;

import org.openqa.selenium.chrome.ChromeDriver;

public class BrowserWindows {

public static void main(String[] args) {

  System.setProperty("webdriver.chrome.driver","C:\\Drivers\\chromedriver_win32\\chromedriver.exe");

  WebDriver driver=new ChromeDriver();

    

  driver.get("http://demo.automationtesting.in/Windows.html");  //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

  {

System.out.println(h);  

     

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

  

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

{

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

}

  }

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

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

Only local connections are allowed.

Please see https://chromedriver.chromium.org/security-considerations 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

CDwindow-588882B4FD6482FCF4122BD4EBC7A14A

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: https://www.seleniumhq.org/exceptions/no_such_element.html

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

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

Driver info: org.openqa.selenium.chrome.ChromeDriver

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(NativeConstructorAccessorImpl.java:64)

at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)

at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)

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.findElementByXPath(RemoteWebDriver.java:428)

at org.openqa.selenium.By$ByXPath.findElement(By.java:353)

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

at day18.BrowserWindows.main(BrowserWindows.java:36)
Nov 25, 2020 in Selenium by faha
• 380 points
4,017 views

1 answer to this question.

0 votes

Hi, @Faha,

As you access the URL http://demo.automationtesting.in/Windows.html 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,770 points
Ok Thanks Gitika.
Error showing up  Unable to click the second page and get title  Any Solution  | Edureka Community
rcjhyxeio http://www.gz98ny146522fnx52scbgyceq21x0166s.org/
<a href="http://www.gz98ny146522fnx52scbgyceq21x0166s.org/">arcjhyxeio</a>
[url=http://www.gz98ny146522fnx52scbgyceq21x0166s.org/]urcjhyxeio[/url]

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 6, 2020 in Selenium by Sri
• 3,190 points
18,910 views
+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
16,242 views
+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,150 points
15,919 views
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 12, 2019 in Selenium by Vaishnavi
• 1,180 points
1,968 views
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,770 points
71,060 views
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,770 points
2,519 views
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