修改细节

This commit is contained in:
halliday2023 2023-05-30 18:45:01 +08:00
parent f6eab77cf3
commit fab80ffbef
4 changed files with 28 additions and 17 deletions

View File

@ -1,8 +0,0 @@
Feature: 检索测试
Scenario: 访问百度并搜索关键字
Given
Then 访"https://www.baidu.com"
And ""
Then

9
features/baidu.feature Normal file
View File

@ -0,0 +1,9 @@
Feature: 百度搜索
Scenario: 搜索关键词
Given behave
When
Then
Then
Then
Then

View File

@ -7,23 +7,27 @@ def step_impl(context, keyword): # context是上下文对象有参数的话
context.keyword = keyword # 将参数绑定上下文对象,以便其他步骤使用
@when('打开百度页面')
def step_impl(context):
context.driver = driver = webdriver.Chrome() # 同样绑定上下文对象
def step_imp2(context):
context.driver = driver = webdriver.Firefox() # 同样绑定上下文对象
driver.implicitly_wait(10)
driver.get('https://www.baidu.com')
@when('输入关键词')
def step_impl(context):
@then('输入关键词')
def step_imp3(context):
context.driver.find_element('id', 'kw').send_keys(context.keyword)
@when('点击百度一下按钮')
def step_impl(context):
@then('点击百度一下按钮')
def step_imp4(context):
context.driver.find_element('id', 'su').click()
sleep(0.5)
sleep(2)
@then('页面标题中应包含关键词')
def step_impl(context):
assert context.keyword in context.driver.title
def step_imp5(context):
assert context.keyword in context.driver.title
@then('关闭浏览器')
def step_imp6(context):
context.driver.quit()

6
start_vscode.bat Normal file
View File

@ -0,0 +1,6 @@
set PROJECT_HOME=%~dp0
rem 确保vscode在path里面
start code %PROJECT_HOME%