2017-04-25 1 views
0

Im folgenden Code Handlingmehrere Fenster in IE und Chrome-Browser

//Element clicked in parent window 
driver.findElement(By.id("ID")).click(); 

//Once after clicking the ID, system takes the user to a different tab in chrome and launches an external link 
//In IE the same external link will launch in a new browser which is different from chrome behavior 

Iterator<String> browsers = driver.getWindowHandles().iterator(); 
while(browsers.hasNext()){ 
driver.switchTo().window(browsers.next()); 

//Element to be clickable in the child window or external site 
driver.findElement(By.xpath(".//button")).click(); 

Kann mir jemand helfen, wie können wir das Szenario umgehen, ich etwas will, die sowohl in IE und Chrome funktioniert. Derzeit funktioniert der obige Code in Chrome, aber nicht im IE, da der externe Link in einem neuen Browser geöffnet wird. Ich bin das Szenario nicht in der Lage

Antwort

0

Versuchen Sie, die folgenden Verfahren für den IE zu handhaben:

Java:

DesiredCapabilities cap = DesiredCapabilities.internetExplorer(); 
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); 
cap.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING,true); 
cap.setCapability(InternetExplorerDriver.UNEXPECTED_ALERT_BEHAVIOR,"accept"); 
cap.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS,true); 
cap.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL,""); 
WebDriver dr = new InternetExplorerDriver(cap); 

C#:

var options = new InternetExplorerOptions(); 
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; 
options.EnsureCleanSession = true; 
options.IgnoreZoomLevel = true; 
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept; 
options.RequireWindowFocus = true; 
options.InitialBrowserUrl = ""; 
string iedriver = TestContext.DataRow["IEDRIVER"].ToString(); 
dr = new InternetExplorerDriver(iedriver,options); 
Verwandte Themen