diff --git a/requirements.txt b/requirements.txt index c23ed596c35..7f6f76e6ced 100755 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ six>=1.10.0 flake8>=3.3.0 requests>=2.13.0 urllib3>=1.20 -BeautifulSoup>=3.2.1 +BeautifulSoup4==4.6.0 unittest2>=1.1.0 chardet>=3.0.2 boto>=2.46.1 diff --git a/seleniumbase/fixtures/base_case.py b/seleniumbase/fixtures/base_case.py index 5b8351843f5..eaba85cf130 100755 --- a/seleniumbase/fixtures/base_case.py +++ b/seleniumbase/fixtures/base_case.py @@ -29,7 +29,7 @@ class MyTestClass(BaseCase): import traceback import unittest import uuid -from BeautifulSoup import BeautifulSoup +from bs4 import BeautifulSoup from pyvirtualdisplay import Display from seleniumbase.config import settings from seleniumbase.core.application_manager import ApplicationManager @@ -160,23 +160,22 @@ def click_link_text(self, link_text, timeout=settings.SMALL_TIMEOUT): element.click() return source = self.driver.page_source - soup = BeautifulSoup(source) - html_links = soup.fetch('a') + soup = BeautifulSoup(source, "html.parser") + html_links = soup.find_all('a') for html_link in html_links: if html_link.text == link_text: - for html_attribute in html_link.attrs: - if html_attribute[0] == 'href': - href = html_attribute[1] - if href.startswith('//'): - link = "http:" + href - elif href.startswith('/'): - url = self.driver.current_url - domain_url = self.get_domain_url(url) - link = domain_url + href - else: - link = href - self.open(link) - return + if html_link.has_attr('href'): + href = html_link.get('href') + if href.startswith('//'): + link = "http:" + href + elif href.startswith('/'): + url = self.driver.current_url + domain_url = self.get_domain_url(url) + link = domain_url + href + else: + link = href + self.open(link) + return raise Exception( 'Could not parse link from link_text [%s]' % link_text) raise Exception("Link text [%s] was not found!" % link_text) diff --git a/server_requirements.txt b/server_requirements.txt index 97ce0d628bc..b720d2d1390 100755 --- a/server_requirements.txt +++ b/server_requirements.txt @@ -9,7 +9,7 @@ six>=1.10.0 flake8>=3.3.0 requests>=2.13.0 urllib3>=1.20 -BeautifulSoup>=3.2.1 +BeautifulSoup4==4.6.0 unittest2>=1.1.0 chardet>=3.0.2 boto>=2.46.1 diff --git a/server_setup.py b/server_setup.py index 61e718626f4..9da8a150bba 100755 --- a/server_setup.py +++ b/server_setup.py @@ -8,7 +8,7 @@ setup( name='seleniumbase', - version='1.3.26', + version='1.3.27', description='Test Automation Framework - http://seleniumbase.com', long_description='Automation Framework for Simple & Reliable Web Testing', platforms='Mac * Windows * Linux * Docker', @@ -29,7 +29,7 @@ 'flake8>=3.3.0', 'requests>=2.13.0', 'urllib3>=1.20', - 'BeautifulSoup>=3.2.1', + 'BeautifulSoup4==4.6.0', 'unittest2>=1.1.0', 'chardet>=3.0.2', 'boto>=2.46.1', diff --git a/setup.py b/setup.py index 29e93c6a925..7a497eb7cbd 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='seleniumbase', - version='1.3.26', + version='1.3.27', description='Test Automation Framework - http://seleniumbase.com', long_description='Automation Framework for Simple & Reliable Web Testing', platforms='Mac * Windows * Linux * Docker', @@ -28,7 +28,7 @@ 'flake8>=3.3.0', 'requests>=2.13.0', 'urllib3>=1.20', - 'BeautifulSoup>=3.2.1', + 'BeautifulSoup4==4.6.0', 'unittest2>=1.1.0', 'chardet>=3.0.2', 'boto>=2.46.1',