提问人:Kevin 提问时间:3/16/2018 更新时间:3/16/2018 访问量:468
Selenium Chrome WebDriver -new-window 参数强制使用小写 URL...是否可以使此大小写敏感?
Selenium Chrome WebDriver -new-window argument forces lowercase URLs... Is it possible to make this case sensitive?
问:
我正在与一个网站合作,显然 URL 的大写很重要。出于其他原因,我需要使用 ChromeWebDriver。基本问题是,当我使用“-new-window”参数输入我的 URL 时,打开的 URL 强制将 URL 全部小写。例如:
ChromeOptions options = new ChromeOptions();
options.AddArgument("-new-window www.example.com/HelloWorld");
m_Browser = new ChromeDriver({path to exe}, options, new TimeSpan(0, 3, 0));
当浏览器窗口打开时,当我需要网站为“www.example.com/HelloWorld”时,网站将更改为“www.example.com/helloworld”
我知道这应该无关紧要,但对于我正在使用它的网站来说,它确实如此 - 如果 URL 的某些部分不是大写字母,那么该网站就找不到正确的页面。是否有其他参数或我缺少的东西来使其区分大小写?
这也有点令人困惑,因为如果我在桌面上制作一个 chrome 快捷方式,然后将“-new-window www.example.com/HelloWorld”添加到目标,它确实会正确地将我带到“www.example.com/HelloWorld”,所以这要么是我的代码中的其他错误,要么是 chrome webdriver 的问题。
我也知道我可以在创建浏览器后手动导航到页面,但我想知道是否有办法使用“-new-window”参数正确执行此操作。
答:
您需要打开带有参数的 url (add extra):-
options.AddArgument("--new-window www.example.com/HelloWorld");
但根据 Peter Beverloo 提供的 ChromeOptions(由 Capabilities 和 ChromeOptions 推荐),这似乎不是正确的选择,因为:
论点:
--new-window Launches URL in new browser window
源代码 :
// Launches URL in new browser window. const char kOpenInNewWindow[] = "new-window";
一个潜在的解决方案是使用 initialBrowserUrl,但到目前为止,此选项似乎仅适用于 IEDriverServer
评论