whats wrong in my code attached below

+1 vote
package com.sv.selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SwitchTabs {
public static void main(String[] args) throws InterruptedException {
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("file:///C:/Users/user/Desktop/html/parent.html");
driver.findElement(By.linkText("goto page2")).click();
Thread.sleep(3000);
String text1=driver.getWindowHandle();
System.out.println(text1);
Set<String> Allids = driver.getWindowHandle();// iam getting error in this line
System.out.println(Allids);
for(String s:Allids)
{
driver.switchTo().window(s);
}
Thread.sleep(3000);
driver.findElement(By.linkText("goto page3")).click();
Thread.sleep(3000);
driver.quit();
}
}
Jan 9, 2020 in Selenium by anonymous
• 130 points
727 views
Hey, could you specify what objective are you trying to accomplish so that it would be better to debug what's missing in the code.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Selenium

0 votes
1 answer

Not able to use “explicit wait” in my code

To wait until the entire data has ...READ MORE

answered Mar 28, 2018 in Selenium by nsv999
• 5,500 points
1,144 views
0 votes
1 answer

unable to launch my first code in eclipse using selenium chrome driver

@klbret, can you share your code or ...READ MORE

answered Oct 10, 2019 in Selenium by Abha
• 28,140 points
1,545 views
0 votes
0 answers

URGENT ! I have a problem in my code. Please Help!!

Hello, I tried to extract data from a ...READ MORE

Apr 24, 2020 in Selenium by anonymous
• 120 points
675 views
0 votes
6 answers

How to specify "ENTER" button functionality in Selenium WebDriver code?

using OpenQA.Selenium.Interactions; Actions builder = new Actions(driver); ...READ MORE

answered Feb 13, 2019 in Selenium by anonymous
95,986 views
0 votes
1 answer

I tried the below code but multiple instances are being created

Remove the driver initialization from @BeforeClass/ returnDriver() ...READ MORE

answered Mar 30, 2018 in Selenium by DragonLord999
• 8,450 points
1,412 views
0 votes
1 answer

Reading data from Excel in my Selenium test

Log4j problems are usually thrown because of ...READ MORE

answered Apr 6, 2018 in Selenium by nsv999
• 5,500 points
10,573 views
0 votes
1 answer

What's the difference between functions getClass() and getAttribute(“class”) in Selenium?

The simple difference is that, getClass() returns ...READ MORE

answered Apr 7, 2018 in Selenium by nsv999
• 5,500 points
12,114 views
0 votes
1 answer

JARS for using Selenium class functions in code

Yup. I'm not sure, exactly which JARS ...READ MORE

answered Apr 12, 2018 in Selenium by nsv999
• 5,500 points
1,577 views
0 votes
1 answer

How do i change the location where my file gets downloaded in Selenium Webdriver and firefox driver?

There are a couple of errors there. ...READ MORE

answered Apr 13, 2018 in Selenium by nsv999
• 5,500 points
6,128 views
+4 votes
2 answers

Can we get the HTTP Response Code in Selenium with Java?

It is indeed possible to get http ...READ MORE

answered Apr 21, 2018 in Selenium by king_kenny
• 3,710 points
41,457 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