From e45ef7a5f74f0288fb7f40778794c2df6f8f1c73 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Wed, 19 Jul 2017 16:54:58 -0400 Subject: [PATCH 1/3] Replace BeautifulSoup with BeautifulSoup4 --- requirements.txt | 2 +- server_requirements.txt | 2 +- server_setup.py | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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/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..4d17ceb749b 100755 --- a/server_setup.py +++ b/server_setup.py @@ -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..8b931ae6800 100755 --- a/setup.py +++ b/setup.py @@ -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', From 3f4b09f4215c447b17d0c3694e5c2343b0e9c8c5 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Wed, 19 Jul 2017 16:55:34 -0400 Subject: [PATCH 2/3] Have base_case use the updated BeautifulSoup4 --- seleniumbase/fixtures/base_case.py | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) 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) From 3acdbe7e788498a3fac0cfc1999788c29eae55f4 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Wed, 19 Jul 2017 16:57:28 -0400 Subject: [PATCH 3/3] Version 1.3.27 --- server_setup.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server_setup.py b/server_setup.py index 4d17ceb749b..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', diff --git a/setup.py b/setup.py index 8b931ae6800..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',