Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Chrome中使用Selenium和Python从dart读取打印语句?_Python_Google Chrome_Selenium_Dart - Fatal编程技术网

如何在Chrome中使用Selenium和Python从dart读取打印语句?

如何在Chrome中使用Selenium和Python从dart读取打印语句?,python,google-chrome,selenium,dart,Python,Google Chrome,Selenium,Dart,我有一个正在测试的基本事件处理程序,它接收用Dart编写的回调: void handleMouseOverEvent(MouseEvent e){ print(' x:'+ e.client.x.toString() + ' y:' + e.client.y.toString()); } 我正在使用Selenium自动执行一个测试,以验证此方法是否被调用。我的计划是写入事件的XY坐标,以验证它是否被调用 我正在使用python selenium脚本来执行此操作: from selenium

我有一个正在测试的基本事件处理程序,它接收用Dart编写的回调:

void handleMouseOverEvent(MouseEvent e){
  print(' x:'+ e.client.x.toString() + ' y:' + e.client.y.toString());
}
我正在使用Selenium自动执行一个测试,以验证此方法是否被调用。我的计划是写入事件的XY坐标,以验证它是否被调用

我正在使用python selenium脚本来执行此操作:

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

from MouseMoves import TestMouseMoves

capabilities = DesiredCapabilities.CHROME
capabilities['loggingPrefs'] = { 'browser':'ALL' }

driver = webdriver.Chrome(desired_capabilities=capabilities)
driver.get("http://localhost:63343/Dart_WebStorm/web/index.html")


TestMouseMoves()

for entry in driver.get_log('browser'):
    print entry

for entry in driver.get_log('driver'):
    print entry

driver.close()
基于(尽管使用Dart而不是Javascript生成日志)

TestMouseMoves是一种通过在屏幕上移动鼠标光标来模拟鼠标移动的方法

我已经验证了我的Dart应用程序正在selenium实例中打印控制台输出。通过删除driver.close()并调查所创建会话的控制台日志,我可以看到以下内容

我不知道为什么在我的两份打印声明中没有看到这些日志。这是仅有的两个可用日志(driver.log_type返回
[u'browser',u'driver']
)。建议也有可用的客户机/服务器日志(但此处似乎未捕获这些日志)

我的python selenium脚本打印出以下消息,这表明正在打印控制台中的第一个条目(它似乎与第一个条目匹配):

{u'source':u'deprecation',u'message':u'deprecation 0:0/deep/combinator已被弃用。有关详细信息,请参阅。',u'timestamp':1448212138717,u'level':u'WARNING'}

我还尝试了
window.console.log('stuff here')而不是Dart记录的打印。我在打印之前增加了4秒的延迟,以帮助解决潜在的时间问题


如何修改Dart和/或Python selenium脚本以检索和打印此鼠标悬停事件生成的日志?

好的,至少我现在理解了您的问题;-)。第一条消息是由Chrome本身生成的。其他的是Dart
print()
stations中的日志语句,前者由selenium提供,后者缺失。您可以尝试直接从Dart调用
window.console.log()
方法,而不是
print()
@GünterZöchbauer我想知道它是否也与selenium相关,只查看浏览器/驱动程序日志(而不是客户机/服务器)在这种情况下?我对Selenium没有足够的经验来强迫他们生成这些日志,但是……我对Selenium也没有太多的经验。