硒的webdriver + PhantomJS保持在约:空白特定站点 [英] Selenium Webdriver + PhantomJS remains at about:blank for a specific site

查看:1200
本文介绍了硒的webdriver + PhantomJS保持在约:空白特定站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用与硒的webdriver PhantomJS并获得成功,但对于一个特定的网站,我看到它并不导航到该网址。我曾与Python和C#试了一下。结果
Python的code:

I am trying to use PhantomJS with Selenium Webdriver and got success but for a specific website I see that it does not navigate to the URL. I have tried it with both Python and C#.
Python Code:

dcap = dict(webdriver.DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36")
service_args = ['--load-images=false', '--proxy-type=None']
driver = webdriver.PhantomJS(executable_path="C:\\phantomjs.exe", service_args=service_args, desired_capabilities=dcap)
driver.get("https://satoshimines.com")
print driver.current_url

这code段的输出是:关于:空白结果
而它工作正常用于其他任何网站。

The output of this code snippet is: about:blank
Whereas it works fine for any other website.

同一code。与C#:

Same code with C#:

IWebDriver driver = new PhantomJSDriver();
driver.Navigate().GoToUrl("https://satoshimines.com");
Console.WriteLine(driver.Url);

C#程序的输出也相同。

The output of the C# program is also same.

我在这里坚持和需要帮助。

I am stuck here and need help.

推荐答案

以下为C#一个完整的code解决方案 -

Following is a complete code solution for c# -

PhantomJSDriverService service = PhantomJSDriverService.CreateDefaultService();
service.IgnoreSslErrors = true;
service.LoadImages = false;
service.ProxyType = "none";

driver = new PhantomJSDriver(service);

这篇关于硒的webdriver + PhantomJS保持在约:空白特定站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆