我使用python + selenium webdriver进行自动化.我已经使用了ImplicitlyWait和WebDriverWait.
问题:
在单个脚本中同时使用ImplicitlyWait和WebDriverWait是一个好习惯吗?
假设我的ImplicitlyWait值为20,WebDriverWait值为10秒.WebDriverWait在等待特定元素时会覆盖20吗?当ImplicitlyWait值小于WebDriverWait时会发生什么?
请建议.我尝试在互联网上找到这个答案,但没有得到任何完整的证据或令人信服的答案.
为了断言页面标题,我不想进行硬检查,而是进行软检查,例如页面标题上的字符串模式匹配。为此,这里是我的代码的摘录,不幸的是它不起作用:
wait = WebDriverWait(self.driver, 15)
wait.until(lambda driver:self.driver.title.lower().startswith('Checkout'))
self.assertIn("Checkout", self.driver.title)
Run Code Online (Sandbox Code Playgroud)
这是页面的确切标题:结账 - HarXYZ
有人可以指出我在哪里犯了错误吗?还有其他方法可以通过字符串模式匹配来断言页面标题吗?
我正在用python创建自动化框架,但是我却坚持创建Web驱动程序的单个实例。这是我的框架设计的摘录:
从硒导入webdriver
类驱动程序:
#创建类变量
实例=无
@staticmethod
def Initialize():
实例= webdriver.Firefox()
返回实例
从驱动程序导入驱动程序
类LoginPage:
@staticmethod
定义GoToURL():
Driver.Instance.get(“样本网址”)
@staticmethod
def Login():
Driver.Instance.find_element_by_id(“ session_key-login”)。send_keys(“ sample@gmail.com”)
Driver.Instance.find_element_by_id(“ session_password-login”)。send_keys(“ sample_password”)
Driver.Instance.find_element_by_id(“ btn-primary”)。click()
问题是Driver.Instance.get()或与此相关的Driver.Instance.find_element ...正在引发错误。可能是这里没有识别Driver.Instance。
一些文章建议 now本身build()包含在内perform(),而另一些文章则建议将build().perform()多个操作链接在一起时使用。