Selenium study notes, selenium
1. I encountered a strange problem today. iframe has two identical IDS (for example)
Use driver. switchTo (). frame ("frmLinkPage1"); this cannot be used.
Later, you can use driver. switchTo (). frame (0 );.
By the way, exit ifrmae.
Driver. switchTo (). defaultContent ();
2. Click a button to open a new window. After processing, close the new window and process the original window. The Code required for this process is as follows.
String detail?whandle = null;
First:
// Obtain the header information of the Main Window
String maindomainwhandle = driver. getdomainwhandle ();
// Obtain the focus switching window of the new window
Set <String> handles = driver. getWindowHandles ();
System. out. println (handles );
Iterator <String> itWin = handles. iterator ();
While (itWin. hasNext ()){
String key = itWin. next ();
If (main1_whandle. equals (key )){
Continue;
}
Detail?whandle = key;
}
// Switch to the new window to get the focus
WebDriver detailWindow = driver. switchTo (). window (detail?whandle );
In the next step,
// Close the new window
DetailWindow. close ();
Handles. remove (detail?whandle );
// Switch back to the main window, and return the focus to the main window again
Driver = driver. switchTo (). window (main1_whandle );