package rjcs; import java.util. *; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support. ui.Select; public class xinkaishi { public static void main (String [] args) { System.setProperty ("webdriver.firefox.bin", "C: \\ Program Files (x86) \\ Mozilla Firefox \\ firefox.exe "); // Set the installation path of Firefox to prevent the system from finding FirefoxDriver driver = new FirefoxDriver (); // Initialize FireFox browser instance and open the browser try { driver.manage (). Window (). Maximize ( ); // Maximize the window Thread.sleep (5000); driver.navigate (). to ("http://yancheng.ganji.com/"); Thread.sleep (5000); String parentWindowHandle = driver.getWindowHandle (); // First store the current browser window handle to a variable in. driver.findElementByLinkText ("Package eat package"). click (); Set <String> allWindowsHandles = driver.getWindowHandles (); // Store all the browser handles that are opened in a set container if (! allWindowsHandles.isEmpty ()) { for (String windowHandle: allWindowsHandles) { System.out.println (driver.switchTo (). window (windowHandle) .getTitle ()); Thread.sleep (10000); } } Thread.sleep(10000); }catch (Exception e) { e.printStackTrace(); }finally { driver.quit(); } } }
Results of the:
[Yancheng Ganji Network] -Free information-Yancheng Classified Information Portal
[Yancheng Job Search | Job Search Information | Yancheng Job Search Website]-Yancheng Ganji Network
【Yancheng job search | Job search information | Yancheng job search website]-Yancheng Ganji
package rjcs; import java.util. *; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support. ui.Select; public class xinkaishi { public static void main (String [] args) { System.setProperty ("webdriver.firefox.bin", "C: \\ Program Files (x86) \\ Mozilla Firefox \\ firefox.exe "); // Set the installation path of Firefox to prevent the system from finding FirefoxDriver driver = new FirefoxDriver (); // Initialize FireFox browser instance and open the browser try { driver.manage (). Window (). Maximize ( ); // Maximize the window Thread.sleep (5000); driver.navigate (). to ("http://yancheng.ganji.com/"); Thread.sleep (5000); String parentWindowHandle = driver.getWindowHandle (); // First store the current browser window handle to a variable in. driver.findElementByLinkText ("Package eat package"). click (); Set <String> allWindowsHandles = driver.getWindowHandles (); // Store all the browser handles that are opened in a set container if (! allWindowsHandles.isEmpty ()) { for (String windowHandle: allWindowsHandles) { System.out.println (driver.switchTo (). window (windowHandle) .getTitle ()); Thread.sleep (10000); } } Thread.sleep(10000); }catch (Exception e) { e.printStackTrace(); }finally { driver.quit(); } } }
Results of the:
[Yancheng Ganji Network] -Free information-Yancheng Classified Information Portal
[Yancheng Job Search | Job Search Information | Yancheng Job Search Website]-Yancheng Ganji Network
【Yancheng job search | Job search information | Yancheng job search website]-Yancheng Ganji