[英]Selenium Python execute script in the Firefox console
I am able to run the following script in Google Chrome console. 我可以在Google Chrome控制台中运行以下脚本。 How can I do this using Selenium Python in Firefox? 如何在Firefox中使用Selenium Python做到这一点?
date1 = "13-11-2015T17:25"
date2 = "25-11-2015T11:01"
window.PF.start_diff(date1, date2)
I tried with driver.executeScript()
, but I do not think I can achieve with this. 我尝试使用driver.executeScript()
,但是我不认为可以做到这一点。 This is what I am trying when I am in the Firefox and Google Chrome console. 这就是我在Firefox和Google Chrome控制台中所要尝试的。 First I log in to the app and execute the script and this is what I get: 首先,我登录到应用程序并执行脚本,这是我得到的:
So it seems like it is working. 因此,似乎正在运行。 Note that the pop up appears after executing the command. 请注意,执行命令后将显示弹出窗口。
I have tried using both of the following: 我尝试使用以下两个:
driver.execute_script("window.PF.start_diff(date1, date2)")
driver.execute_script(window.PF.start_diff(date1, date2))
Also tried this: driver.execute_async_script
还尝试了这个: driver.execute_async_script
我想您没有定义date1和date2,请尝试以下操作:
driver.execute_script("date1 = '13-11-2015T17:25'; date2 = '25-11-2015T11:01'; return window.PF.start_diff(date1, date2);")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.