【发布时间】:2018-12-28 06:14:28
【问题描述】:
如何在 Gmails.SetPassword 中传递 row[0,1] 的值。请建议更改相同的值。下面是相同的代码。
module Gmails
extend RSpec::Matchers
extend Capybara::DSL
$Gmails_Username_Input= "//input[@id='identifierId']"
$Gmails_IdentifierNext_Button="div[id= 'identifierNext']"
$Gmails_Password_Input="input[name= 'password']"
$Gmails_PasswordNext_Button="div[id='passwordNext']"
book = Spreadsheet.open('Data.xls')
sheet1 = book.worksheet('Sheet1') # can use an index or worksheet name
sheet1.each do |row|
break if row[0].nil? # if first cell empty
puts row.join(',') # looks like it calls "to_s" on each cell's Value
puts row[0,1]
end
def Gmails.OpenGmail
visit "https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin"
end
def Gmails.SetEmailId
Gmails.SetElement $Gmails_Username_Input, row[0,1]
end
def Gmails.ClickNext
Gmails.ClickElement $Gmails_IdentifierNext_Button
end
def Gmails.SetPassword
Gmails.SetElement $Gmails_Password_Input, row[1,1]
end
def Gmails.ClickPasswordNext
Gmails.ClickElement $Gmails_PasswordNext_Button
end
def Gmails.ClickElement objectpath
if(objectpath.start_with?('/'))
find(:xpath, objectpath).click
else
find(:css, objectpath).click
end
end
def Gmails.SetElement objectpath ,gmailsTextValue
if(objectpath.start_with?('/'))
find(:xpath, objectpath).set gmailsTextValue
else
find(:css, objectpath).set gmailsTextValue
end
end
end
【问题讨论】:
-
Ruby 不是 Javascript...
-
@ManishaSingh:对于您发布的代码,我认为您不会收到此错误消息,因为没有引用模块
Gmails::Username。错误消息指的是哪个行号?