我正在尝试创建可重用的Wait,但始终收到此错误WebDriverWait(self.driver, 10).until(
AttributeError: 'str' object has no attribute 'driver'
我的代码:
在Browser.Py中,我有
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class Browser(object):
def wait_for(self, locator):
WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located(locator))
我尝试通过以下方式调用它:
from features.browser import Browser
from features.locators import Locators
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
class Steps(Browser):
def delete_from_cart2(self):
Browser.wait_for(*Locators.DELETE_FROM_CART2)
答案 0 :(得分:0)
wait_for
可能是这样
def wait_for(self, driver, locator):
WebDriverWait(driver, 10).until(
EC.presence_of_element_located(locator))
驱动程序实例可以传递给变量。