我的文件夹是
功能/features_files_folder
功能/步骤
在features_files_folder
Omniwyse.feature
法典:
特征:全能
@tagcurrent
Scenario Outline: COMPANY
Given I load the website "https://www.omniwyse.com"
When I click "About Us" page
Then verify about header element "About Us"
初始化.py
步骤中文件夹
step_def_web_element_handling.py
from behave import given, when, then
from step_impl_web_element_handling import webapp
@given(u'I load the website "{url}"')
def step_impl(context,url):
webapp.load_website(url)
@when(u'I click "About Us" page')
def step_impl_goto_page(context):
webapp.goto_page()
@then(u'verify about header element "{component}"')
def step_impl_verify_component(context, component):
webapp.verify_component_exists(component)
step_impl_web_element_handling.py
from selenium import webdriver
driverpath = "/Users/giris/Downloads/chromedriver"
class WebApp:
def __init__(self):
pass
# self.driver.get("https://omniwyse.com/")
def load_website(self, url):
driver = webdriver.Chrome(executable_path = driverpath)
driver.get(url)
def goto_page(self):
driver = webdriver.Chrome(executable_path = driverpath)
driver.find_element_by_xpath("//a[normalize-space()='About Us']").click()
def verify_component_exists(self, component):
# Simple implementation
driver = webdriver.Chrome(executable_path = driverpath)
assert component in driver.find_element_by_xpath("//h1[contains(text(),'About Us')]"),
"Component {} not found on page".format(component)
webapp = WebApp()
我的错误step_def_web_element_handling
{
"resource": "/c:/Users/giris/OneDrive/Documents/pythonassignment/omni/features/steps/step_def_web_element_handling.py",
"owner": "python",
"code": "no-name-in-module",
"severity": 8,
"message": "No name 'then' in module 'behave'",
"source": "pylint",
"startLineNumber": 4,
"startColumn": 1,
"endLineNumber": 4,
"endColumn": 1
}
给定时相同,当
使用 beact 命令运行时的输出
使用默认路径"./features" 尝试基目录: C:\Users\giris\OneDrive\Documents\pythonassignment\omni\features 功能: Omniwyse # features/feature_files_folder/omniwyse.feature:1
1 个功能通过,0 个失败,0 个跳过 0 个方案通过,0 个失败,0 个 跳过 0 步 通过,0 失败,0 跳过,0 未定义 花了 0m0.000s
期望输出:
使用默认路径"./features" 尝试基目录: C:\Users\giris\OneDrive\Documents\pythonassignment\omni\features 功能: Omniwyse # features/feature_files_folder/omniwyse.feature:1
1 个功能通过,0 个失败,0 个跳过 1 个方案通过,0 个失败,0 个 跳过 3 个步骤 通过,0 个失败,0 个跳过,0 个未定义 花了 0m0.000s
In omniwyse.feature
将方案大纲替换为方案