这是我的step_definitions中的ruby文件:
require 'rubygems'
require 'appium_lib'
require 'yaml'
desired_caps = {
caps: {
platformName: 'iOS',
platformVersion: '11.4',
deviceName: 'iPhone 7',
app: 'PATH',
},
appium_lib: {
sauce_username: nil,
sauce_access_key: nil,
#wait: 100
}
}
driver = Appium::Driver.new(desired_caps,)
$driver.start_driver
#login layout test
#finding the merrill logo
def logo (driver)
if driver.find_element(:name, "logo")
return driver.find_element(:name,"logo")
end
end
#finding the email textfield
def email(driver)
if driver.find_element(:xpath, '//XCUIElementTypeApplication[@name="DataSiteOne"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTextField')
return driver.find_element(:xpath, '//XCUIElementTypeApplication[@name="DataSiteOne"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTextField')
end
end
#finding the password textfield
def password(driver)
if driver.find_element(:xpath, '//XCUIElementTypeApplication[@name="DataSiteOne"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeSecureTextField')
return driver.find_element(:xpath, '//XCUIElementTypeApplication[@name="DataSiteOne"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeSecureTextField')
end
end
#finding the email toggle
def toggle(driver)
if driver.find_element(:xpath, '//XCUIElementTypeApplication[@name="DataSiteOne"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeSwitch')
return driver.find_element(:xpath, '//XCUIElementTypeApplication[@name="DataSiteOne"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeSwitch')
end
end
#finding the remember me button
def rememberMeButton(driver)
if driver.find_element(:name, "Remember me")
return driver.find_element(:name, "Remember me")
end
end
#finding the login button
def loginButton(driver)
if driver.find_element(:name, "Login")
return driver.find_element(:name, "Login")
end
end
#finding Forgot Password button
def forgotPasswordButton(driver)
if driver.find_element(:name, "Forgot your password?")
return driver.find_element(:name, "Forgot your password?")
end
end
Then(/^I verify the login screen layout$/) do
$driver.start_driver
logo(driver)
email(driver)
password(driver)
toggle(driver)
rememberMeButton(driver)
loginButton(driver)
forgotPasswordButton(driver)
end
$driver.driver_quit
这是Cucumber文件
@LoginLayout
Feature: Test
As an investment banker or analyst
I want to be able to make a decision about a current acquisition or merger
@ValidLayout
Scenario: All elements exist on the page for the user
Then I verify the login screen layout
此测试的目的是发现视图控制器上存在所有UI元素,ruby文件运行但是当我与黄瓜一起运行时它失败并且无法识别star_driver方法。我似乎无法弄清楚为什么它没有识别该文件。
答案 0 :(得分:0)
我没有运行appium,我以为我做了,但我没有。