简体   繁体   中英

Selenium Python execute script in the Firefox console

I am able to run the following script in Google Chrome console. How can I do this using Selenium Python in Firefox?

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. This is what I am trying when I am in the Firefox and Google Chrome console. 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

我想您没有定义date1和date2,请尝试以下操作:

driver.execute_script("date1 = '13-11-2015T17:25'; date2 = '25-11-2015T11:01'; return window.PF.start_diff(date1, date2);")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM