javascript - 尝试执行 driver.execute_script(gooogletag

标签 javascript python-3.x selenium

当我使用 Selenium 运行 googletag 参数时,我尝试从浏览器的控制台中获取一些响应,但不幸的是我没有。

我已经尝试过 .execute_async_script('googletag.pubads()')也可以将所有内容放入尝试/执行中,但即使我没有得到任何答复,也永远不会调用执行。

这是我的代码:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

url = 'https://joursferies.fr'

d = DesiredCapabilities.CHROME
d['loggingPrefs'] = { 'browser':'ALL' }
browser = webdriver.Chrome(desired_capabilities=d)
browser.get(url)
browser.execute_script('googletag.openConsole()')

# Until here everything is perfect but with the following line is when I never get any answer:

browser.execute_script('googletag.pubads()')

我期望浏览器检查中的控制台会向我显示信息,但它没有显示任何内容。

最佳答案

尝试添加 return,browser.execute_script('return googletag.openConsole()')

关于javascript - 尝试执行 driver.execute_script(gooogletag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58523897/

相关文章:

javascript - 删除重复的数组值然后存储它们 [react]

python - PyQt显示数据框的tableview垂直标题

python-3.x - Pandas - 有条件的删除重复项

python - 在继承的数据类中使用 __new__

css - 如何使用 Selenium IDE 单击 Gmail 中的特定电子邮件?

javascript - Ember.js - Ember 数据不返回模型

javascript - 有没有办法将对象中的值映射到 javascript 中的数组索引?

javascript - 如何启用长按操作以在 android WebView 中下载图像?

java - 调用 WebElement 列表的单个索引

java - 如何通过selenium读取UL类弹出窗口上显示的文本