How can we get Watir-Webdriver to work with the IE invalid cert screen?

梦想的初衷 提交于 2019-12-01 21:15:44

I've done a bit of experimenting, including using the HTML I posted to create my own page, sans any JavaScript. If I work with that page, I find it blocks JavaScript actions. In that case, when I try to do things like browser.text, or browser.link.exists?, I see an IE warning popup that tells me that IE is preventing JS from working on that page. (something I never see on the actual cert error page) And in watir-webdriver I get the same errors that I reported. If I click the choice to allow JS, then I can work with the page in watir-webdriver.

So it appears something in in the very nature of the page is preventing any JS level automation which blocks Webdriver's access to the page.

I see why MS is doing this, they don't want a bogus site to somehow use JavaScript to get around that warning. Apparently the way Watir drives things (via OLE?) isn't seen as something you could do remotely and thus is allowed access to the page.

The solution then is to either use Watir for your IE automation, or make it so the certificate is trusted and thus you do not see the warning.

If you want to use Watir-Webdriver, then you need to add the certificates used on your test servers to the Trusted Root Certification Authorities store. Note NOT the default 'personal' store! When adding the cert, you need to change where it's going to put the cert or you are basically only doing a one time for that session authorization. There will be a warning that now all certificates from that authoritiy will be trusted. I would use this with great care, only on test systems, and only for trusting certs from your own internal test servers.

It's pretty easy to do this after manually proceeding to the page, via double-clicking the red warning reminding you the cert is invalid. If you've done that right, you can close the browser, re-open, do your navigation and not get an error.

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