【问题标题】:C# Selenium Chrome change homepageC# Selenium Chrome 更改主页
【发布时间】:2018-02-23 19:08:33
【问题描述】:

我正在尝试更改 chrome 默认主页(谷歌标签),但我没有找到可行的解决方案。 我尝试过的:

var _options = new ChromeOptions();
_options.AddUserProfilePreference("homepage", "http://www.example.com");
_options.AddUserProfilePreference("homepage_is_newtabpage", true);
_options.AddUserProfilePreference("session.restore_on_startup", 4);
_options.AddUserProfilePreference("session.startup_urls", new List<string>() { "http://in.gr"});
_options.AddArgument("--homepage=http://in.gr");
var _driver = new ChromeDriver(_options);

【问题讨论】:

    标签: c# google-chrome selenium selenium-webdriver selenium-chromedriver


    【解决方案1】:

    您可以在初始化 WebDriver 之后导航到您想要的页面,然后再开始进行其余的 Web 自动化操作。

    ...
    var _driver = new ChromeDriver(_options);
    _driver.Navigate().GoToUrl("http://in.gr");
    

    希望对您有所帮助。

    【讨论】:

    • 感谢您的回复,但导航不是一个选项。我正在尝试更改默认主页,因为所有扩展都在谷歌默认主页启动后加载。例如代理身份验证扩展有时需要时间来加载和代理身份验证提示出现在谷歌默认主页上。
    猜你喜欢
    • 2020-03-29
    • 1970-01-01
    • 2015-04-25
    • 2013-11-06
    • 2015-02-24
    • 2021-05-09
    • 1970-01-01
    • 2013-01-28
    • 2014-06-22
    相关资源
    最近更新 更多