【问题标题】:No answer trying to execute driver.execute_script(gooogletag [closed]尝试执行 driver.execute_script(gooogletag [关闭]
【发布时间】:2019-10-23 13:23:26
【问题描述】:

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

我已经尝试过使用 .execute_async_script('googletag.pubads()') 以及将所有内容都放在 try/execute 中,但即使我没有得到任何回复,也不会调用执行。

这是我的代码:

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()')

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

【问题讨论】:

    标签: javascript python-3.x selenium


    【解决方案1】:

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-14
    • 2012-05-12
    • 2020-03-31
    • 1970-01-01
    • 2020-12-30
    • 2020-04-21
    • 1970-01-01
    • 2010-11-05
    相关资源
    最近更新 更多