自动化Gmail使用Watir注册的问题

时间:2016-09-20 10:53:07

标签: ruby automated-tests watir-webdriver

我正在使用Watir自动化gmail注册,我在设置月份下拉框时遇到错误。我无法选择确切的月份。我正在使用Windows7上的Firefox进行测试。请在下面找到我的源代码并请帮助我

require 'watir-webdriver'
  require "watir-webdriver/wait"
  ie=Watir::Browser.new :firefox
  ie.goto "gmail.com"
  ie.text_field(:id,"FirstName").set("Info")  
  ie.text_field(:id,"LastName").set("Gain")  
  ie.text_field(:id,"GmailAddress").set("infoblr123")   
  ie.text_field(:id,"Passwd").set("infoblr123$")   
  ie.text_field(:id,"PasswdAgain").set("infoblr123$")   
  ie.element(:css, "#BirthMonth > div").click
  ie.element(:text, "May").click
  ie.text_field(:id, "BirthDay").set "11"
  ie.text_field(:id, "BirthYear").set "1992

2 个答案:

答案 0 :(得分:0)

您好以上代码选择月份好,这里没有问题。但是你错过了一行'ie.link(:text,'Create account')。点击'这里。

require 'watir-webdriver'
require "watir-webdriver/wait"
ie=Watir::Browser.new :chrome
ie.goto "gmail.com"
ie.link(:text,'Create account').click # you have missed out this line
ie.text_field(:id,"FirstName").set("Info")
ie.text_field(:id,"LastName").set("Gain")
ie.text_field(:id,"GmailAddress").set("infoblr123")
ie.text_field(:id,"Passwd").set("infoblr123$")
ie.text_field(:id,"PasswdAgain").set("infoblr123$")
ie.element(:css, "#BirthMonth > div").click
ie.element(:text, "May").click
ie.text_field(:id, "BirthDay").set "11"
ie.text_field(:id, "BirthYear").set "1992"

答案 1 :(得分:0)

Firefox 45正常运行:https://ftp.mozilla.org/pub/firefox/releases/45.4.0esr/

请降级到该版本,然后重试;我刚刚运行你的脚本没有错误。 (当然,在添加ie.link(:text,'Create account').click之后)。