New window handles disappearing in IE, can't switch to new window

前端 未结 2 1031
鱼传尺愫
鱼传尺愫 2021-01-07 11:46

I am using the latest version of Selenium (2.37.0) with C# in Internet Explorer 10 (using the latest 32-bit InternetExplorerDriver, 2.37.0) to log in to a webpage, click on

2条回答
  •  不要未来只要你来
    2021-01-07 11:57

    Just wanted to give an update, in case anyone else has this same problem and finds this page. I haven't found a solution to my problem, but I came up with a workaround.

    Originally, I was clicking on a link that opened a new window, and I was having trouble navigating Selenium to the new window. What I did instead was dig through the page's source code, find the button that I was clicking on, and figure out where that button points to. It would have been easiest if it was a simple hyperlink (www.whatever.com/....), but instead it was a Javascript function. That Javascript function builds up the hyperlink using some fixed characters and some variables; for example:

    link(username, date) = "http://www.google.com/user=" + username + "?date=" + date;
    

    So, going along with this example, I just figured out what variables were being fed in (username, date, etc.), built the URL myself, and navigated to it directly. Thus I didn't even have to open up and navigate to a new window at all.

提交回复
热议问题