【发布时间】:2020-05-16 03:30:37
【问题描述】:
编写我的 Ruby-Watir-cucumber bdd 测试我得到了这个:
NoMethodError: undefined method `msg=' for #<Watir::Browser:0x0000558fbcdc0cc0>
./features/support/pages/message_page.rb:27:in `escribir'
./features/step_definitions/message_steps.rb:14:in `/^I'm able to write and send a "([^"]*)" successfully$/'
./features/send_messages.feature:12:in `Then I'm able to write and send a "Robot message" successfully'
./features/send_messages.feature:9:in `Then I'm able to write and send a "<message>" successfully'
1 scenario (1 failed)
4 steps (1 failed, 3 passed)
0m12.939s
Process finished with exit code 1
当我已经定义了方法时:
class MessagePage
include PageObject
@@browser = Watir::Browser.new
page_url 'https://www.linkedin.com/messaging/'
text_field(:searchcontact, name: 'searchTerm')
div(:txtmessage,:role => "textbox")
button(:btnsend,:type => 'submit')
div(:txtfield,:xpath =>"//div//div[@role='textbox']")
text_field(:mensaje,:xpath =>"//div//div[@role='textbox']")
div(:msg,:role => "textbox") /// HERE!!!
def searchcontact contact
self.searchcontact = contact
#searchcontact(contact).send_keys(:enter)
wait 5
end
def buscar contact
wait_until do
searchcontact_element.visible?
self.searchcontact = contact
end
self.searchcontact = contact
end
def escribir (message)
self.msg = message
wait 5
end
def writemessage message
wait_until do
msg_element.visible?
self.msg = message
end
self.msg = message
end
def sendmessage
btnsend
end
end
【问题讨论】:
标签: ruby cucumber bdd watir page-object-gem