MarketSquare / robotframework-angularjs

An AngularJS and Angular extension to Robotframework's SeleniumLibrary
Apache License 2.0
34 stars 20 forks source link

Override ngElementFinder class doesn't have and _s2l attribute #6

Closed emanlove closed 8 years ago

emanlove commented 8 years ago

Didn't see this error before but in an internal application we saw

14:59:06.140    FAIL       AttributeError: 'ngElementFinder' object has no attribute '_s2l'
14:59:06.141    DEBUG
Traceback (most recent call last): File "<decorator-gen-42>",line 2,
in get_text File "C:\Python27\lib\site-packages\Selenium2Library\keywords\keywordgroup.py", line 15,
in _run_on_failure_decorator return method(*args, **kwargs) File "C:\Python27\lib\site-packages\Selenium2Library\keywords\_element.py", line 312,
in get_text return self._get_text(locator) File "C:\Python27\lib\site-packages\Selenium2Library\keywords\_element.py", line 700,
in _get_text element = self._element_find(locator, True, True) File "C:\Python27\lib\site-packages\Selenium2Library\keywords\_element.py", line 678,
in _element_find elements = self._element_finder.find(browser, locator, tag) File "C:\Python27\lib\site-packages\Selenium2Library\locators\elementfinder.py", line 37,
in find return strategy(browser, criteria, tag, constraints) File "C:\Python27\lib\site-packages\AngularJSLibrary\__init__.py", line 29,
in _find_by_default return self._s2l._element_finder._find_by_xpath(browser, criteria, tag, constraints)

Make sense as that class has no definition of _s2l. Interesting I needed to run a modified set [1] of Selenium2Library tests to see it. More interesting only three of tests failed and all of these were recent changes for the WebElements addition. Mmmmm... [Running commentary as I debug tests...]

Ok. Modified unit tests [2] this time but still interesting found only one failing test. Seems like we have very little checks on using the shortcut locator for xpath.

[1] Simply modified test\acceptance\resource.robot to include the AngularJS Library

*** Setting ***
Library           Selenium2Library    run_on_failure=Nothing    implicit_wait=0
Library           AngularJSLibrary
Library           Collections
Library           OperatingSystem

*** Variable ***
#...

[2] Modified tests\unit\locators\test_elementfinder.py

import unittest
import os
#from Selenium2Library.locators import ElementFinder
from AngularJSLibrary import ngElementFinder as ElementFinder
from mockito import *
from robot.utils.asserts import assert_raises_with_msg

# ...
emanlove commented 8 years ago

Fixed with 76b1ca634232351e5b67b70f350a27e78cb9c04d.

[Notes it always help to correctly reference the issue #. This #6 not #2 ;)]