【问题标题】:ruby watir classic won't authenticate proxyruby watir classic 不会验证代理
【发布时间】:2023-04-07 18:22:01
【问题描述】:

我尝试使用我的代码通过 watir-webdriver 打开 Internet Explorer:

require "watir-webdriver"


profile = Selenium::WebDriver::Firefox::Profile.new
profile.proxy = Selenium::WebDriver::Proxy.new :http => 'http://username:password@xx.xxx.xxx.xx:xxxxx', :ssl => 'http://username:password@xx.xxx.xxx.xx:xxxxx'

我得到这个错误,说明我在猜测? 它是这样写的:

C:/Ruby/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/profile.rb:205:in `Integer': invalid value for Integer(): "//username:password@xx.xxx.xxx.xx:xxxxx" (ArgumentError)
    from C:/Ruby/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/profile.rb:205:in `set_manual_proxy_preference'
    from C:/Ruby/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/profile.rb:176:in `proxy='
    from test1.rb:6:in `<main>'

【问题讨论】:

  • 我也试过'.start'方法...
  • 我无法为您提供 watir-classic 代码,但我鼓励您评估更新到 watir-webdriver,因为这是该项目所有持续开发重点所在。
  • 我在 ie 上使用了 webdrver 并且遇到了同样的问题@titusfortner
  • 我可以帮你。通过添加 webdriver 堆栈跟踪来更新您的问题,我们会弄明白的。
  • @titusfortner 我改变了我的问题,这是我在尝试使用 firefox 验证代理时遇到的错误。

标签: ruby authentication proxy watir-webdriver watir-classic


【解决方案1】:

我至少可以解释错误。您不能将基本身份验证传递给代理 url,因为代码期望字符串中的冒号用于区分主机和端口(需要是整数。

我没有太多使用 Selenium 代理的经验。在互联网上四处寻找问题提供建议,例如在您指定的 Firefox 配置文件中将 signon.autologin.proxy 设置为 true,或添加 Firefox autoauth 扩展。本质上,您可以在个人资料中手动保存一次密码,然后自动化测试就不必输入它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-31
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多