require 'watir-webdriver'
require 'win32ole'
require 'roo'
b= Watir::Browser.new(:firefox)
b.goto('https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=http://mail.google.com/mail/&scc=1<mpl=default<mplcache=2')
xl = WIN32OLE.new('excel.application')
wrkbook= xl.Workbooks.Open("C:\\Excel\\mondial1.xlsx")
wrksheet= wrkbook.Worksheets(1)
wrksheet.Select
username1= wrksheet.Range("a1").Value
password1= wrksheet.Range("b1").Value
b.text_field(:id, "Email").set("username1")
b.text_field(:id, "Passwd").set("password1")
b.button(:id, "signIn").click
xl.Quit我只想打开一个Excel表并从那里获取值,我需要将它作为gmail中textfield的输入。
不是直接从Excel *获得值,而是直接设置为"username1“*,我需要通过Excel传递值--请提前提供建议,谢谢
发布于 2013-03-18 12:42:15
问题
排在队伍里
b.text_field(:id, "Email").set("username1")将字符串"username1“传递给set方法。这就是为什么输入到文本字段中的值。
溶液
您实际上要做的是传递变量username1的值。这是通过使它成为set方法的参数来完成的。
b.text_field(:id, "Email").set(username1)请注意,username1周围没有引号。password1变量也需要类似的条件。
https://stackoverflow.com/questions/15475855
复制相似问题