FindLinks broken ?
Hi ! I'm receiving an exception when I try to use the links property like this :
elements = browser.find_by_css(".link").links.find_by_partial_href(URL)
return [a["href"] for a in elements]
Here's the relevent part of the traceback :
File "/home/edited_out/venv/lib/python3.8/site-packages/splinter/driver/webdriver/__init__.py", line 205, in find_by_partial_href
return self.parent.find_by_xpath(
TypeError: find_by_xpath() got an unexpected keyword argument 'original_find'
https://github.com/cobrateam/splinter/blob/3bee3089e299f50ef7062b2e1892cd14f03a11f8/splinter/driver/webdriver/init.py#L207
I tried to remove all original_find and original_query from the FindLinks class and now it works fine !
Python 3.8 splinter 0.13.0 Firefox 72.0.2 geckodriver 0.26.0
Similar issue : #426
The solution is the opposite. WebDriverElement's find_by_xpath method should take original_find and original_query as optional arguments.
How about ?
diff --git a/splinter/driver/webdriver/__init__.py b/splinter/driver/webdriver/__init__.py
index 8f52138..68d860f 100644
--- a/splinter/driver/webdriver/__init__.py
+++ b/splinter/driver/webdriver/__init__.py
@@ -855,11 +855,12 @@ class WebDriverElement(ElementAPI):
wait_time=wait_time,
)
- def find_by_xpath(self, selector, wait_time=None):
+ def find_by_xpath(self, selector, wait_time=None, original_find="xpath", original_query=None):
return self.find_by(
self._element.find_elements_by_xpath,
selector,
- original_find="xpath",
+ original_find=original_find,
+ original_query=original_query,
wait_time=wait_time,
)
@ShellCode33 Makes sense to me. If the tests pass you should open a PR for the fix.
Fixed by #758