Microsoft Edge clean session

做~自己de王妃 提交于 2019-12-10 16:07:45

问题


Microsoft Edge driver does not ensure clean session whenever it runs selenium tests. Is there an option I can specify to desired capabilities to fix this?


回答1:


Just encounter that issue myself today so the only way I got it to work was pretty simple in the end. You have to check "Always clear this when I close the browser" in Edge settings (and select the things that you want to clear).

With that setting you will have clean session on each new driver initialization :)




回答2:


Another solution could be to open Edge in Private Mode (at least solved my problems with session and clearing cookies):

EdgeOptions options = new EdgeOptions();
options.AddAdditionalCapability("InPrivate", true);
this.edgeDriver = new EdgeDriver(options);



回答3:


From my experience, the only way to achieve a clean session in Edge is to build it as you go. What I mean is, you must clear cookies and reload screens where necessary.

An example would be a login screen which navigates to a landing page having a popup arrive ~1-3 seconds after load.

  • Edge login pages typically don't logout the previous tests user so a Logout is often required at the beginning of these test steps if Browser=Edge.

  • The first time this all happens locally, the driver sees the popup, it's dismissed, and a cookie gets created which prevents the popup from triggering for the next test.

I don't know about your test framework, but I use ConfirmOnThisPage() methods anytime I move from one page to another. So, once I know the page has loaded, I can easily handle cookies about to be tested here with a call to a DeleteCookie(Cookie cookie) function which contains a page refresh from within my page confirmation method. I use the following:

public IWebDriver DeleteCookie(Cookie cookie){
    driver.Manage().Cookies.DeleteCookieNamed(cookie);
    driver.Navigate().Refresh(); 
    return driver;
}


来源:https://stackoverflow.com/questions/39619076/microsoft-edge-clean-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!