Ruby Watir Webdriver - 登录时如何在Facebook / Google弹出窗口中识别并输入电子邮件和密码?

时间:2017-05-15 15:29:33

标签: ruby facebook cucumber watir watir-webdriver

Ruby Watir Webdriver - 如何在登录时识别并输入Facebook / Google弹出窗口中的电子邮件和密码?

页:

Facebook: 

<label class="login_form_label">Email or Phone:</label>
        <input type="text" class="inputtext _55r1 inputtext inputtext" name="email" id="email" tabindex="1" value="" autofocus="1">

Google:
  <input type="email" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="username" spellcheck="false" tabindex="0" aria-label="Email or phone" name="identifier" id="identifierId" dir="ltr" data-initial-dir="ltr" data-initial-value="">

                <div jsname="YRMmle" class="AxOyFc snByac" aria-hidden="true">Email or phone</div>

WATIR代码: Facebook的:

 Then(/^I enter "([^"]*)" in the email field or phone field$/) do |arg|
      browser.element(:id,"email").send_keys(arg)
    end

谷歌:

 Then(/^I click on field with text "([^"]*)" in div class identifier"([^"]*)"$/) do |arg1, arg2|
      browser.div(:text,"Email or phone").div(:class,"AxOyFc snByac").click
    end

例外:

Facebook:

Scenario: As a user i am able to login to ChefD website via Facebook # features/Sanity_scenarios.feature:27
    When I click on span text identifier "log in / sign up"            # Features/Step_definitions/ChefD.rb:16
    When I click on span text identifier "Log in with Facebook"        # Features/Step_definitions/ChefD.rb:16
This code has slept for the duration of the default timeout waiting for an Element to exist. If the test is still passing, consider using Element#exists? instead of rescuing UnknownObjectException
      #Then I bring facebook browser to front
    Then I enter "ytest27@gmail.com" in the email field or phone field # Features/Step_definitions/ChefD.rb:119
      timed out after 30 seconds, waiting for #<Watir::HTMLElement: located: false; {:id=>"email"}> to be located (Watir::Exception::UnknownObjectException)
      ./Features/Step_definitions/ChefD.rb:120:in `/^I enter "([^"]*)" in the email field or phone field$/'
      features/Sanity_scenarios.feature:31:in `Then I enter "ytest27@gmail.com" in the email field or phone field'

Google:
Scenario: As a user i am able to login to ChefD website via Google # features/Sanity_scenarios.feature:33
    When I click on span text identifier "log in / sign up"          # Features/Step_definitions/ChefD.rb:16
    And I click on span text identifier "Log in with Google"         # Features/Step_definitions/ChefD.rb:16
This code has slept for the duration of the default timeout waiting for an Element to exist. If the test is still passing, consider using Element#exists? instead of rescuing UnknownObjectException
    Then I click on field with text "" in div class identifier""     # Features/Step_definitions/ChefD.rb:191
      timed out after 30 seconds, waiting for #<Watir::Div: located: false; {:text=>"Email or phone", :tag_name=>"div"}> to be located (Watir::Exception::UnknownObjectException)
      ./Features/Step_definitions/ChefD.rb:192:in `/^I click on field with text "([^"]*)" in div class identifier"([^"]*)"$/'
      features/Sanity_scenarios.feature:36:in `Then I click on field with text "" in div class identifier""'

任何人都可以帮我识别并在弹出窗口中输入文字进行登录吗?

0 个答案:

没有答案