我有2个文件-
conftest.py:
import pytest
from selenium import webdriver
driver = None
@pytest.fixture(autouse = True)
def browserSetAndClose():
global driver
EXE_PATH = r'C:\Users\1602746\Softwares\chromedriver.exe'
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(executable_path = EXE_PATH, options =
chromeOptions, desired_capabilities = chromeOptions.to_capabilities())
driver.implicitly_wait(10)
driver.maximize_window()
driver.get('http://the-internet.herokuapp.com/')
yield driver
driver.quit()
test_ABTesting.py:
import pytest
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
import conftest
@pytest.fixture
def goToABTestingPage():
wait = WebDriverWait(conftest.driver, 10)
wait.until(expected_conditions.element_to_be_clickable((By.XPATH, "//a[starts-with(@href, '/abtest')]"))).click()
def test_abTest_header(goToABTestingPage):
a = conftest.driver.find_element_by_css_selector("h3").text
assert 'A/B Test' in a
def test_abTest_paragraph(goToABTestingPage):
a = conftest.driver.find_element_by_xpath("//p[contains(text(),'Also known as split testing. This is a way in which businesses are able to simultaneously test and learn different versions of a page to see which text and/or functionality works best towards a desired outcome (e.g. a user action such as a click-through).')]").text
assert 'Also known as split testing. This is a way in which businesses are able to simultaneously test and learn different versions of a page to see which text and/or functionality works best towards a desired outcome (e.g. a user action such as a click-through).' in a
我还添加了魅力库。现在,我通过运行以下命令来运行2个测试用例:
pytest test_ABTesting.py
我不断收到此错误:
AttributeError:模块'allure'没有属性'severity_level'
不确定是什么意思。