简体   繁体   English

Firefox控制台中的Selenium Python执行脚本

[英]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.

相关问题 在 crontab 中执行 Python (selenium) 脚本 - Execute Python (selenium) script in crontab Python 使用 selenium 执行脚本 - Python execute script using selenium 如何在 Firefox python selenium 中打开控制台? - How to open console in firefox python selenium? Firefox in Python Selenium: driver.execute_script attempting to remove text characters with JQuery gives "SecurityError: The operation is insecure" - Firefox in Python Selenium: driver.execute_script attempting to remove text characters with JQuery gives "SecurityError: The operation is insecure" 如何使用 Python+Selenium 从 execute_script 获取 JS 控制台响应代码? - How do I get JS Console response code from execute_script with Python+Selenium? Selenium Python加载页面和脚本(Firefox和IE) - Selenium Python Load Page and Script (Firefox and IE) Python Selenium - 适用于 Chrome、Firefox 和 IE 的通用脚本 - Python Selenium - Common Script for Chrome, Firefox & IE Selenium + firefox:空的execute_script参数 - Selenium+firefox: empty execute_script arguments Spyder - 如何在当前控制台中执行 python 脚本? - Spyder - how to execute python script in the current console? Python:在Windows上执行console_script - Python: Execute console_script on windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM