import time
import self as self
from pytest import mark
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from setuptools import setup
@mark.execute
class First_Tests:
def test_first(self, setup):
driver = setup['driver']
browser = setup['browser']
driver.get("https://shuftipro.com/")
driver.maximize_window()
def header_test(self, setup):
driver = setup['driver']
# Click on solution in header
solution = driver.find_element(By.ID, "menu-item-72751")
solution.click()
if driver.current_url == "https://shuftipro.com/solutions/":
print("land on solution page.")
else:
print("land on wrong page.")
obj = First_Tests()
obj.test_first(self, setup)
obj.header_test(self, setup)
如果我从参数中删除“self”并运行程序,它会显示错误:test_first()接受1个位置参数,但实际上给出了3个
1条答案
按热度按时间f4t66c6m1#
其中一个更简单的方法是使用selenium中的webdriver
driver = webdriver.Chrome()
并除去了
然后去掉setup作为参数。最后的代码看起来像这样: