在gmail注册期间使用Watir访问Birthday变量时出错

时间:2015-05-04 14:56:33

标签: ruby watir watir-webdriver firewatir

我正在尝试通过watir创建gmail帐户。作为其中的一部分,当我尝试使用div元素选择生日时,我无法做到。

我尝试了下面的一个:

char

我的系统配置:

@ie.div(:text,'May').click

4 个答案:

答案 0 :(得分:2)

我一直不喜欢看到这里的答案,说“你为什么要这样做?”或“你为什么要这样做?”。所以我只会说“不要这样做!”。我确定无论你自动创建gmail帐户,都可以解决你遇到的任何问题。

如果您只需要一个唯一的Gmail地址,请参阅以下链接: http://www.codestore.net/store.nsf/unid/BLOG-20111201-0411

另一个选项是https://mailinator.com/

答案 1 :(得分:0)

您无法点击页面上不可见的内容。您首先需要打开下拉列表:

browser.span(id: 'BirthMonth').click
browser.div(text: 'May').click

答案 2 :(得分:0)

As @titusfortner indicates, that element cannot be selected/clicked because it is not visible. Using watir-webdriver, this snippet makes the dropdown menu visible so its options can be selected:

b.div(title: "Birthday").when_present.click
b.div(text: "May").when_present.click

That being said, there are two other (read: larger) issues:

  1. You won't be able to script your way past the captcha.
  2. Google doesn't want you doing this. That's why the captcha is there, and they'll eventually block your IP if you consistently automate/script against them.

答案 3 :(得分:0)

b.element(:css, '#BirthMonth > div').click
b.element(:text, 'May').click

它适用于ChromeFirefox但也不完美