0

는, 내가이 시나리오에 직면 UI 자동화 수행하려고 열려있을 때 하나 windowhandle 카운트 통과 :에, InternetExplorer1에서
을 내 webapp에서 탭의 메뉴를 클릭하면 새로 추가 InternetExplorer2 인스턴스가 URL을로드합니다. 그래서 나는 두 개의 IE를 얻는다. 이제 IE2로 전환하고 거기에서 로그 아웃 버튼을 클릭해야합니다. 이것에 대한 나는 코드가 있습니다driver.WindowHandles 그냥 거기에 인터넷 익스플로러의 두 인스턴스가있어 셀레늄 WebDriver를 사용

[Test] 
public void mytest() 
{ 
    Assert.IsTrue(IsOpen()); 
} 

public bool IsOpen() 
{ 
    GoToUrl();// I pass the URL over here and the element is clicked here 
    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(15)); 
    SwitchWindow(); 

    return true; 
} 

//Here I switch the window. 
private void SwitchWindow() 
{ 
    IJavaScriptExecutor js = driver as IJavaScriptExecutor; 
    var currentWindow = driver.CurrentWindowHandle; 
    string currentWindowTitle = (string)js.ExecuteScript("return document.title"); 
    var availableWindows = new List<string>(driver.WindowHandles); 

    foreach (string w in availableWindows) 
    { 
     if (w != currentWindow) 
     { 
      //This should switch the window. 
      driver.SwitchTo().Window(w); 
      //.......................... 
      //.........More of my automation runs here.......... 
      //........................... 

     } 
    } 
} 

을하지만 목록은 WindowHandles에 하나 개의 항목을 통과 availablewindows. 두 개의 인스턴스를 열어두면 안됩니까?

+0

브라우저를로드하고 링크를 클릭하면 코드를 보는 것이 유용 할 수 있습니다. 드라이버 인스턴스가 같다고 가정하면이 코드에 아무런 문제가 보이지 않습니다. 그러나, 그것은 가치가있다 [이] (http://stackoverflow.com/questions/19575095/new-window-handles-disappearing-in-ie-cant-switch-to-new-window) 그래서 그들이 보이는 것 질문 문제가 발생했습니다 (IE 만 해당). – Corporalis

답변

0

InternetExplorer2가 동일한 IE 인스턴스의 새 탭이 아닌 IE의 새 인스턴스로 실행되는 경우 InternetExplorerDriver가이를 볼 수 있다고 생각하지 않습니다.

IE 설정을 변경하여 모든 것이 새 인스턴스가 아닌 새 인스턴스에서 시작되도록하거나 새 IE 인스턴스에서 URL을 가져오고 새 InternetExplorerDriver를 사용하여 다시 실행하도록 코드를 작성할 수 있습니다 (I 've 've 've C#으로이 작업을 성공적으로 수행 할 수 있었지만 정상적으로 작동했지만 웹 응용 프로그램의 작동 방식에 따라 다를 수 있습니다.

관련 문제