Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed strict version dependency to selenium #109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions helium/_impl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ElementNotVisibleException, MoveTargetOutOfBoundsException, \
WebDriverException, StaleElementReferenceException, \
NoAlertPresentException, NoSuchWindowException
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import Select
Expand Down Expand Up @@ -797,7 +798,8 @@ def find_all_in_curr_frame(self):
x_path = self.get_xpath()
return self._sort_search_result(
list(map(
WebElementWrapper, self._driver.find_elements_by_xpath(x_path)
WebElementWrapper, self._driver.find_elements(By.XPATH, x_path)
#WebElementWrapper, self._driver.find_elements_by_xpath(x_path)
))
)
def _sort_search_result(self, search_result):
Expand Down Expand Up @@ -940,7 +942,9 @@ def _find_elts(self, xpath=None):
if xpath is None:
xpath = self.get_xpath()
return list(map(
WebElementWrapper, self._driver.find_elements_by_xpath(xpath)
WebElementWrapper, self._driver.find_elements(By.XPATH, xpath)
#WebElementWrapper, self._driver.find_elements_by_xpath(xpath)

))
def _find_elts_by_free_text(self):
elt_types = [
Expand Down
21 changes: 12 additions & 9 deletions helium/_impl/selenium_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ def get_distance_to_last_manipulated(self, web_element):
# No .location. This happens when last_manipulated_element is an
# Alert or a Window.
return 0
def find_elements_by_name(self, name):
def find_elements(self, by, xpath):
# Selenium sometimes returns None. For robustness, we turn this into []:
return self.target.find_elements_by_name(name) or []
def find_elements_by_xpath(self, xpath):
# Selenium sometimes returns None. For robustness, we turn this into []:
return self.target.find_elements_by_xpath(xpath) or []
def find_elements_by_css_selector(self, selector):
# Selenium sometimes returns None. For robustness, we turn this into []:
return self.target.find_elements_by_css_selector(selector) or []
return self.target.find_elements(by, xpath) or []
#def find_elements_by_name(self, name):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the PR. But please don't have dead (commented-out) code in your PR. I will not ever have dead code in my repositories.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay!

# # Selenium sometimes returns None. For robustness, we turn this into []:
# return self.target.find_elements_by_name(name) or []
#def find_elements_by_xpath(self, xpath):
# # Selenium sometimes returns None. For robustness, we turn this into []:
# return self.target.find_elements_by_xpath(xpath) or []
#def find_elements_by_css_selector(self, selector):
# # Selenium sometimes returns None. For robustness, we turn this into []:
# return self.target.find_elements_by_css_selector(selector) or []
def is_firefox(self):
return self.browser_name == 'firefox'
@property
Expand Down Expand Up @@ -166,4 +169,4 @@ def switch_to_frame(self, frame_index_path):
self.driver.switch_to.frame(frame_index)

class FramesChangedWhileIterating(Exception):
pass
pass
Binary file modified helium/_impl/webdrivers/linux/chromedriver
Binary file not shown.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
packages = find_packages(exclude=['tests', 'tests.*']),
install_requires = [
# Also update requirements/base.txt when you make changes here.
'selenium==3.141.0'
'selenium>=3.141.0'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This permits Selenium 3.141.0. Will your By. changes still work with Selenium 3?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that to support both major release, a version check must be added.

],
package_data = {
'helium._impl': ['webdrivers/**/*']
Expand All @@ -37,4 +37,4 @@
'Operating System :: MacOS :: MacOS X'
],
test_suite='tests'
)
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't unnecessarily change the white space. See https://gist.github.com/mherrmann/5ce21814789152c17abd91c0b3eaadca.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I immagine this is due to my editor settings.