I'd appreciate any help on this issue.
I'm trying to click (to expand) all years and months elements on this page:
<tbody ng-repeat="year">
<tr class="year expandable title">
<th><a>2020</a></th>
</tr>
<tr class="month expandable title ng-hide">
<th><a><span class="display">December 2020</span></a></th>
</tr>
<!-- [...] ALL OTHER MONTHS, SAME STRUCTURE -->
</tbody>
<tbody ng-repeat="year">
<tr class="year expandable title">
<th><a>2019</a></th>
</tr>
<tr class="month expandable title ng-hide">
<th><a><span class="display">December 2019</span></a></th>
</tr>
<!-- [...] ALL OTHER MONTHS, SAME STRUCTURE -->
</tbody>
When trying this code below I always get a Lookup error.
for y in find_all(S('.year.expandable')):
click(y)
for m in find_all(S('.month.expandable')):
click(m)
Here's the traceback:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/local/lib/python3.9/site-packages/helium/__init__.py", line 273, in click
_get_api_impl().click_impl(element)
File "/usr/local/lib/python3.9/site-packages/helium/_impl/__init__.py", line 202, in click_impl
self._perform_mouse_action(element, self._click)
File "/usr/local/lib/python3.9/site-packages/helium/_impl/__init__.py", line 37, in f_decorated
result = f(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/helium/_impl/__init__.py", line 56, in f_decorated
return f(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/helium/_impl/__init__.py", line 240, in _perform_mouse_action
self._manipulate(element, lambda wew: action(wew.unwrap(), offset))
File "/usr/local/lib/python3.9/site-packages/helium/_impl/__init__.py", line 301, in _manipulate
driver.last_manipulated_element = gui_or_web_elt.perform(action)
File "/usr/local/lib/python3.9/site-packages/helium/_impl/__init__.py", line 648, in perform
raise LookupError()
LookupError
Not sure why but it works If I click on just one element click(S('.year.expandable'))
Any idea what could be wrong?
The DOM appear to be changing upon interaction hence the error. I found a workaround without using Helium. I wrote a custom function that uses
driver.find_elements_by_xpath(xpath)to spot and click the DOM elements using selenium.The code does the trick. Not entirely sure why but I had to add
highlight(S(xpath))to make sure to have the click go through, otherwise the code randomly returnes aStaleElement Exception.I know it's hacky but if anyone else has a better solution please feel free to comment.