4

I have a basic event handler I am testing receives a callback, written in Dart:

void handleMouseOverEvent(MouseEvent e){
  print(' x:'+ e.client.x.toString() + ' y:' + e.client.y.toString());
}

I am using Selenium to automate a test verifying this method is called. My plan is to write the XY coordinates of the event to verify it is called.

I am using a python selenium script to do this:

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

Based on Getting console.log output from Chrome with Selenium Python API bindings (though using Dart and not Javascript for log generation).

TestMouseMoves is a method to fake mouse movement by moving my mouse cursor all over the screen.

I have verified that my Dart application is printing console output in the selenium instance. By removing the driver.close() and investigating the console log for the created session, I see the below.

enter image description here

I do not know why I am not seeing these logs in my two print statements. Those are the only two logs available (driver.log_types returns [u'browser', u'driver']). Selenium documentation suggests there are also client/server logs available (but these do not seem to be captured here).

My python selenium script prints out the below message, which suggests the first entry in the console is being printed (it appears to match the first entry):

{u'source': u'deprecation', u'message': u'deprecation 0:0 /deep/ combinator is deprecated. See https://www.chromestatus.com/features/6750456638341120 for more details.', u'timestamp': 1448212138717, u'level': u'WARNING'}

I have also tried window.console.log('stuff here'); instead of print for the Dart logging as well. And I have added a 4 second delay before my print to help with potential timing issues.

How can I modify either my Dart and/or Python selenium script to retrieve and print the logs generated by this mouseover event?

Community
  • 1
  • 1
enderland
  • 13,825
  • 17
  • 98
  • 152
  • Ok, at least I now understand your question ;-). The first message is generated by Chrome itself. The others are log statements from Dart `print()` statments, the former are provided by selenium, the later are missing. – Günter Zöchbauer Nov 22 '15 at 17:21
  • You could try to call `window.console.log()` methods directly from Dart instead of `print()` [DartPad](https://dartpad.dartlang.org/1f7565df6d1b9c6ad8ce) – Günter Zöchbauer Nov 22 '15 at 17:31
  • @GünterZöchbauer I am wondering if it also relates to Selenium only seeing browser/driver logs (and not client/server) in this case? I am not experienced enough with Selenium to try to force them to generate those logs, however... – enderland Nov 22 '15 at 17:35
  • I also don't have much experience with Selenium yet. – Günter Zöchbauer Nov 22 '15 at 17:37

0 Answers0