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
59 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
146 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,800 points
131 views
0 votes
3 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
22,534 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,400 points
64 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
6,706 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
5,566 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
404 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
2,352 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
20,460 views
0 votes
1 answer

Source code to find element in Selenium-java

You are probably looking at the WebDriver interface alone. But, ...READ MORE

answered Apr 24, 2018 in Selenium by king_kenny
• 3,710 points
668 views