Python selenium-在(myFunc)使用WebDriver之外的函数之前,WebDriverWait()可以吗?

Python selenium-在(myFunc)使用WebDriver之外的函数之前,WebDriverWait()可以吗?,python,function,selenium,selenium-webdriver,Python,Function,Selenium,Selenium Webdriver,是否可以在.until中调用WebDriver之外的函数?无论我尝试什么,我都会得到一个例外: Exception: 'WebDriver' object has no attribute 'verifyObj_tag'. 我有一个名为“ad_selenium”的类,所有对selenium的调用都封装在库中。我编写的explicitWait函数正在尝试在中使用另一个类方法。直到: def explicitWait(self,tag_name,search_for,element=None,c

是否可以在.until中调用WebDriver之外的函数?无论我尝试什么,我都会得到一个例外:

Exception: 'WebDriver' object has no attribute 'verifyObj_tag'. 
我有一个名为“ad_selenium”的类,所有对selenium的调用都封装在库中。我编写的explicitWait函数正在尝试在中使用另一个类方法。直到:

def explicitWait(self,tag_name,search_for,element=None,compare='contains',seconds=20):
    element = WebDriverWait(self.__WD, seconds).until( lambda self: \
        self.verifyObj_tag(tag_name,search_for,element=element,compare=compare))
我尝试过lambda函数和函数变量的各种组合,如:

def explicitWait(self,tag_name,search_for,element=None,compare='contains',seconds=20):
    x = self.verifyObj_tag
    element = WebDriverWait(self.__WD, seconds).until( lambda x: \
        x(tag_name,search_for,element=element,compare=compare))
查看selenium/webdriver/support/wait.py中的代码,它似乎总是将webriver传递给在中传递的方法,直到:

def until(self, method, message=''):
    while(True):
        try:
            value = method(self._driver)   #<<--webdriver passed here
            if value:
                return value
        except self._ignored_exceptions:
            pass
def-until(self,method,message=''):
虽然(正确):
尝试:

value=method(self.\u driver)#您需要让它作为参数传递
驱动程序

element = WebDriverWait(self.__WD, seconds).until(lambda driver: \
    self.verifyObj_tag(tag_name, search_for, element=element, compare=compare))

为了完整性起见,您能否展示一下什么是
verifyObj_tag()
,以及一个
explicitWait()
用法示例?谢谢。我原以为我完全明白我在做什么,但这证明我在这方面做得太过火了。这很有效。我不明白的是它为什么起作用。因此,我定义了一个名为“driver”的函数变量,但从未在调用中使用它。任何我能完全理解的指针都将非常感谢。@SecondGear当然,请在
中查看此
方法(self.\u driver)
函数调用直到
method
是我们的
lambda
函数,它正在调用
verifyObj_标记
方法内部-换句话说,函数调用函数。这有助于理解吗?谢谢