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 in Selenium by anonymous
• 130 points
89 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 27, 2018 in Selenium by nsv999
• 5,510 points
222 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
• 27,930 points
316 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 in Selenium by anonymous
• 120 points
86 views
0 votes
4 answers

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

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

answered Feb 12, 2019 in Selenium by anonymous
39,845 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 29, 2018 in Selenium by DragonLord999
• 8,450 points
99 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,510 points
7,701 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,510 points
7,870 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,510 points
535 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 12, 2018 in Selenium by nsv999
• 5,510 points
3,275 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 20, 2018 in Selenium by king_kenny
• 3,710 points
27,166 views