试图使Driver.get()适用于多个不同的URL,但这似乎是不可能的,因为.get必须包含字符串,不能包含字符串变量,也不能在此过程中将其转换为字符串
driver1 = webdriver.Chrome()
TradeURL1 = "https://app.libertex.com/products/crypto/Bitcoin/" #User stated
#driver1.execute_script(driver1.get(str(TradeURL1)))
driver1.get(TradeURL1)#https://app.libertex.com/products/metal/XAUUSD
将URL声明为变量,并将变量名称放置在.get中。脚本必须是字符串错误
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: 'script' must be a string
但是像这样放置URL
driver1.get("https://app.libertex.com/products/metal/XAUUSD")
很好用。如果不能在其中放置变量名(URL在整个代码中都在变化),您应该如何使代码具有多功能性并进行调整 除了使用多个驱动程序,还有其他解决方法吗(因为我甚至不知道我将使用多少个驱动程序+使用多个驱动程序需要更多的处理能力并且效率低下)
类似问题 enter link description here
在@DeepSpace之后编辑
driver1 = webdriver.Chrome()
TradeURL1 = "https://app.libertex.com/products/crypto/Bitcoin/" #User stated
#driver1.execute_script(driver1.get(str(TradeURL1)))
driver1.get(TradeURL1)#https://app.libertex.com/products/metal/XAUUSD
time.sleep(5)
driver1 = login()
driver1=login() login()是我构建的一个子例程,当我运行代码时(适用于实际将字符串放入get时),它工作正常。 但是当使用driver1.get(TradeURL1)运行时 显示此错误
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"#login-field"}
回溯到目前为止我所做的事情..将driver1.get(“实际字符串”)更改为driver1.get(TradeURL1),问题是脚本必须是字符串错误。。。我不知道你是@DeepSpace
目前没有回答
相关问题 更多 >
编程相关推荐