使用Watir访问网页元素进行gmail注册

时间:2013-10-05 18:03:04

标签: ruby watir watir-webdriver

我正在gmail登录页面上处理示例gmail登录应用程序。

当我点击创建帐户链接新页面显示时,在此页面中我想访问月份(在生日部分下)。

我尝试使用div元素它给出了一个错误,请你帮我解决。?

2 个答案:

答案 0 :(得分:1)

请尝试一下,它会正常工作

require 'watir-webdriver'

ie=Watir::Browser.new :firefox

ie.goto "https://accounts.google.com/SignUp?continue=https%3A%2F%2Fwww.google.co.in%2Fsearch%3Fq%3Dgoog%26oq%3Dgoog%26aqs%3Dchrome..69i57j69i60l5.807j0%26sourceid%3Dchrome%26espv%3D210%26es_sm%3D93%26ie%3DUTF-8&hl=en"

ie.div(:text,"Month").click

#here you can put your month you want to select
ie.div(:text,"March").click


#select date here
ie.text_field(:id, "BirthDay").set "11"

#select year here
ie.text_field(:id, "BirthYear").set "1992"

答案 1 :(得分:1)

我觉得你很困惑在哪里点击选择月份。实际上当你点击基于id的div时,javascript会运行。

ie.div(:text,"Month").click
//here you can place any month with correct name
ie.div(:text,"March").click