目前正在进行一个小项目,以获得自动化的窍门,并且想知道如何在url重定向到某个页面时打印显示登录状态
if a is "https://pepsi.fooji.com/?#choose-address"
print(f"[{datetime.now()}] - Logged in!")
https://www.selenium.dev/selenium/docs/api/py/api.html
https://www.selenium.dev/selenium/docs/api/py/webdriver_remote/selenium.webdriver.remote.webdriver.html?highlight=current_url selenium.webdriver.remote.webdriver.WebDriver.current_url
if driver.current_url is "https://pepsi.fooji.com/?#choose-address"
print(f"[{datetime.now()}] - Logged in!")
引用python类,如果你引用webdriver远程类,你可以有一个内置的current_url属性,它会给出页面的当前url
is
将返回True
如果两个变量指向同一个对象。其中==
将返回True
如果变量所引用的对象相等
你可以在"=="one_answers"女儿家吗?
解决方案作为解决方案,您可以在通过driver.current_url
返回的字符串中验证字符串https://pepsi.fooji.com/?#choose-address
,如下所示:
if "https://pepsi.fooji.com/?#choose-address" in driver.current_url:
print(f"[{datetime.now()}] - Logged in!")
在driver.current_url
返回的字符串中验证部分字符串choose-address
的最佳方法如下:
if "choose-address" in driver.current_url:
print(f"[{datetime.now()}] - Logged in!")