Skip to content

Commit 7b2a0e6

Browse files
authored
Merge pull request #366 from seleniumbase/demo-mode-updates
Demo Mode updates / JS library version updates
2 parents 0dd767a + 1b06983 commit 7b2a0e6

File tree

9 files changed

+66
-28
lines changed

9 files changed

+66
-28
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/sb_media_logo.png" title="SeleniumBase" height="129">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)<br />
22
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/SB_Logo4d4.png" title="SeleniumBase" height="56">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
33

4-
[<img src="https://img.shields.io/github/release/seleniumbase/SeleniumBase.svg" />](https://github.com/seleniumbase/SeleniumBase/releases) [<img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" />](https://dev.azure.com/seleniumbase/seleniumbase/_build/latest?definitionId=1&branchName=master) [<img src="https://travis-ci.org/seleniumbase/SeleniumBase.svg?branch=master" alt="Build Status" />](https://travis-ci.org/seleniumbase/SeleniumBase) [<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt="Join the SeleniumBase Gitter chat" />](https://gitter.im/seleniumbase/SeleniumBase) [<img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" alt="MIT License" />](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE) [<img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg" alt="Stars" />](https://github.com/seleniumbase/SeleniumBase/stargazers) [<img src="https://img.shields.io/github/repo-size/seleniumbase/seleniumbase.svg" alt="Size" />](https://github.com/seleniumbase/SeleniumBase/releases)<br />
4+
[<img src="https://img.shields.io/github/release/seleniumbase/SeleniumBase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/releases) [<img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" alt=" " />](https://dev.azure.com/seleniumbase/seleniumbase/_build/latest?definitionId=1&branchName=master) [<img src="https://travis-ci.org/seleniumbase/SeleniumBase.svg?branch=master" alt=" " />](https://travis-ci.org/seleniumbase/SeleniumBase) [<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt=" " />](https://gitter.im/seleniumbase/SeleniumBase) [<img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE) [<img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/stargazers) [<img src="https://img.shields.io/github/repo-size/seleniumbase/seleniumbase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/releases)<br />
55

66
Fast, easy, and reliable test automation.
77

@@ -15,7 +15,7 @@ SeleniumBase is an all-in-one test automation framework that uses WebDriver APIs
1515

1616
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Quick Start:
1717

18-
You'll need **[Python](https://www.python.org/downloads/)** [<img src="https://img.shields.io/badge/python-2.7,_3.5,_3.6,_3.7+-22AADD.svg" alt="Python versions" />](https://www.python.org/downloads/)
18+
You'll need **[Python](https://www.python.org/downloads/)** [<img src="https://img.shields.io/badge/python-2.7,_3.5,_3.6,_3.7+-22AADD.svg" alt=" " />](https://www.python.org/downloads/)
1919

2020
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Install/upgrade ``pip``:
2121

@@ -28,7 +28,7 @@ python -m easy_install -U pip
2828

2929
You may want to use a **Python Virtual Environment** to isolate Python dependencies between projects. (The Seleniumbase virtualenv tutorial can be found **[here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md)**, and the official virtualenv tutorial can be found **[here](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)**.)
3030

31-
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Install ``seleniumbase``: [<img src="https://img.shields.io/badge/pypi-seleniumbase-22AAEE.svg" alt="pypi" />](https://pypi.python.org/pypi/seleniumbase)
31+
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Install ``seleniumbase``: [<img src="https://img.shields.io/badge/pypi-seleniumbase-22AAEE.svg" alt=" " />](https://pypi.python.org/pypi/seleniumbase)
3232
```bash
3333
pip install seleniumbase
3434
```
@@ -446,7 +446,7 @@ If you want to type in special keys, that's easy too. Here's an example:
446446

447447
```python
448448
from selenium.webdriver.common.keys import Keys
449-
self.find_element("textarea").send_keys(Keys.SPACE + Keys.BACK_SPACE + '\n') # the backspace should cancel out the space, leaving you with the newline
449+
self.find_element("textarea").send_keys(Keys.SPACE + Keys.BACK_SPACE + '\n') # The backspace should cancel out the space, leaving you with the newline
450450
```
451451

452452
#### Getting the text from an element on a page
@@ -564,7 +564,7 @@ What if your test opens up a new tab/window and now you have more than one page?
564564
Ex:
565565

566566
```python
567-
self.switch_to_window(1) # this switches to the new tab (0 is the first one)
567+
self.switch_to_window(1) # This switches to the new tab (0 is the first one)
568568
```
569569

570570
**ProTip™:** iFrames follow the same principle as new windows - you need to specify the iFrame if you want to take action on something in there
@@ -574,7 +574,7 @@ Ex:
574574
self.switch_to_frame('ContentManagerTextBody_ifr')
575575
# Now you can act inside the iFrame
576576
# .... Do something cool (here)
577-
self.switch_to_default_content() # exit the iFrame when you're done
577+
self.switch_to_default_content() # Exit the iFrame when you're done
578578
```
579579

580580
#### Handle Pop-Up Alerts
@@ -690,13 +690,13 @@ from seleniumbase.fixtures.email_manager import EmailManager, EmailException
690690
num_email_results = 0
691691
email_subject = "This is the subject to search for (maybe include a timestamp)"
692692
email_manager = EmailManager("{YOUR SELENIUM GMAIL ACCOUNT EMAIL ADDRESS}")
693-
# the password for this would be stored in seleniumbase/config/settings.py
693+
# The password for this would be stored in seleniumbase/config/settings.py
694694
try:
695695
html_text = email_manager.search(SUBJECT="%s" % email_subject, timeout=60)
696696
num_email_results = len(html_text)
697697
except EmailException:
698698
num_email_results = 0
699-
self.assert_true(num_email_results) # true if not zero
699+
self.assert_true(num_email_results) # True if not zero
700700
```
701701

702702
Now you can parse through the email if you're looking for specific text or want to navigate to a link listed there.
@@ -708,8 +708,8 @@ Now you can parse through the email if you're looking for specific text or want
708708
<i>**Questions or Comments?**</i><br />
709709
[![Join the chat at https://gitter.im/seleniumbase/SeleniumBase](https://badges.gitter.im/seleniumbase/SeleniumBase.svg)](https://gitter.im/seleniumbase/SeleniumBase?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br />
710710

711-
If you see something, say something! We are very active in resolving issues. [<img src="https://img.shields.io/github/issues-closed-raw/seleniumbase/SeleniumBase.svg" alt="Closed Issues" />](https://github.com/seleniumbase/SeleniumBase/issues?q=is%3Aissue+is%3Aclosed)
711+
If you see something, say something! We are very active in resolving issues. [<img src="https://img.shields.io/github/issues-closed-raw/seleniumbase/SeleniumBase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/issues?q=is%3Aissue+is%3Aclosed)
712712

713713
[https://github.com/mdmintz](https://github.com/mdmintz)<br />
714714

715-
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_7a.png" title="SeleniumBase" height="45">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md) <br /> [<img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" alt="MIT License" />](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE)
715+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_7a.png" title="SeleniumBase" height="45">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md) <br /> [<img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE)

examples/master_qa/basic_masterqa_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class MasterQATests(MasterQA):
66
def test_masterqa(self):
77
self.open("https://xkcd.com/1700/")
88
self.verify("Do you see a webcomic?")
9-
self.highlight_click("link=Store")
9+
self.open("https://store.xkcd.com/collections/everything")
1010
self.highlight_click('[title="things for walls"]')
1111
self.verify('Do you see posters for sale?')
1212
self.highlight_update_text("input.search-input", "book\n")

examples/master_qa/masterqa_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_xkcd(self):
1616
self.verify("Can you find the moon?")
1717
self.click('a[rel="next"]')
1818
self.verify("Do the drones look safe?")
19-
self.click_link_text('Store')
19+
self.open("https://store.xkcd.com/collections/everything")
2020
self.update_text("input.search-input", "book\n")
2121
self.verify("Do you see books in the search results?")
2222
self.open("https://xkcd.com/213/")

examples/visual_testing/layout_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_applitools_helloworld(self):
2020
self.check_window(name="helloworld", level=2)
2121
with self.assertRaises(Exception):
2222
self.check_window(name="helloworld", level=3)
23-
# Now that we know the exception was raised as expected,
23+
# Now that we know the Exception was raised as expected,
2424
# let's print out the comparison results by running in Level-0.
25+
# (NOTE: Running with level-0 will print but NOT raise an Exception.)
2526
self.check_window(name="helloworld", level=0)

seleniumbase/fixtures/base_case.py

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ def get_link_status_code(self, link, allow_redirects=False, timeout=5):
16611661
def assert_link_status_code_is_not_404(self, link):
16621662
status_code = str(self.get_link_status_code(link))
16631663
bad_link_str = 'Error: "%s" returned a 404!' % link
1664-
self.assert_not_equal(status_code, "404", bad_link_str)
1664+
self.assertNotEqual(status_code, "404", bad_link_str)
16651665

16661666
def assert_no_404_errors(self, multithreaded=True):
16671667
""" Assert no 404 errors from page links obtained from:
@@ -1676,6 +1676,10 @@ def assert_no_404_errors(self, multithreaded=True):
16761676
else:
16771677
for link in links:
16781678
self.assert_link_status_code_is_not_404(link)
1679+
if self.demo_mode:
1680+
messenger_post = ("ASSERT NO 404 ERRORS")
1681+
js_utils.post_messenger_success_message(
1682+
self.driver, messenger_post, self.message_duration)
16791683

16801684
def print_unique_links_with_status_codes(self):
16811685
""" Finds all unique links in the html of the page source
@@ -1790,19 +1794,39 @@ def assert_downloaded_file(self, file):
17901794

17911795
def assert_true(self, expr, msg=None):
17921796
self.assertTrue(expr, msg=msg)
1797+
if self.demo_mode:
1798+
messenger_post = ("ASSERT TRUE: {%s}" % expr)
1799+
js_utils.post_messenger_success_message(
1800+
self.driver, messenger_post, self.message_duration)
17931801

17941802
def assert_false(self, expr, msg=None):
17951803
self.assertFalse(expr, msg=msg)
1804+
if self.demo_mode:
1805+
messenger_post = ("ASSERT FALSE: {%s}" % expr)
1806+
js_utils.post_messenger_success_message(
1807+
self.driver, messenger_post, self.message_duration)
17961808

17971809
def assert_equal(self, first, second, msg=None):
17981810
self.assertEqual(first, second, msg=msg)
1811+
if self.demo_mode:
1812+
messenger_post = ("ASSERT EQUAL: {%s == %s}" % (first, second))
1813+
js_utils.post_messenger_success_message(
1814+
self.driver, messenger_post, self.message_duration)
17991815

18001816
def assert_not_equal(self, first, second, msg=None):
18011817
self.assertNotEqual(first, second, msg=msg)
1818+
if self.demo_mode:
1819+
messenger_post = ("ASSERT NOT EQUAL: {%s != %s}" % (first, second))
1820+
js_utils.post_messenger_success_message(
1821+
self.driver, messenger_post, self.message_duration)
18021822

18031823
def assert_title(self, title):
18041824
""" Asserts that the web page title matches the expected title. """
18051825
assert self.get_title() == title
1826+
if self.demo_mode:
1827+
messenger_post = ("ASSERT TITLE: {%s}" % title)
1828+
js_utils.post_messenger_success_message(
1829+
self.driver, messenger_post, self.message_duration)
18061830

18071831
def assert_no_js_errors(self):
18081832
""" Asserts that there are no JavaScript "SEVERE"-level page errors.
@@ -1811,6 +1835,7 @@ def assert_no_js_errors(self):
18111835
* See https://github.com/SeleniumHQ/selenium/issues/1161
18121836
Based on the following Stack Overflow solution:
18131837
* https://stackoverflow.com/a/41150512/7058266 """
1838+
time.sleep(0.1) # May take a moment for errors to appear after loads.
18141839
try:
18151840
browser_logs = self.driver.get_log('browser')
18161841
except (ValueError, WebDriverException):
@@ -2317,7 +2342,7 @@ def assert_exact_text(self, text, selector="html", by=By.CSS_SELECTOR,
23172342

23182343
if self.demo_mode:
23192344
selector, by = self.__recalculate_selector(selector, by)
2320-
messenger_post = ("ASSERT TEXT {%s} in %s: %s"
2345+
messenger_post = ("ASSERT EXACT TEXT {%s} in %s: %s"
23212346
% (text, by, selector))
23222347
self.__highlight_with_assert_success(messenger_post, selector, by)
23232348
return True
@@ -2387,6 +2412,11 @@ def assert_partial_link_text(self, partial_link_text,
23872412
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
23882413
timeout = self.__get_new_timeout(timeout)
23892414
self.wait_for_partial_link_text(partial_link_text, timeout=timeout)
2415+
if self.demo_mode:
2416+
messenger_post = (
2417+
"ASSERT PARTIAL LINK TEXT {%s}." % partial_link_text)
2418+
self.__highlight_with_assert_success(
2419+
messenger_post, partial_link_text, by=By.PARTIAL_LINK_TEXT)
23902420
return True
23912421

23922422
############
@@ -2591,6 +2621,13 @@ def check_window(self, name="default", level=0, baseline=False):
25912621
if level != 0 and level != 1 and level != 2 and level != 3:
25922622
raise Exception('Parameter "level" must be set to 0, 1, 2, or 3!')
25932623

2624+
if self.demo_mode:
2625+
raise Exception(
2626+
"WARNING: Using Demo Mode will break layout tests "
2627+
"that use the check_window() method due to custom "
2628+
"HTML edits being made on the page!\n"
2629+
"Please rerun without using Demo Mode!")
2630+
25942631
module = self.__class__.__module__
25952632
if '.' in module and len(module.split('.')[-1]) > 1:
25962633
module = module.split('.')[-1]
@@ -2685,22 +2722,22 @@ def check_window(self, name="default", level=0, baseline=False):
26852722
page_data_domain = self.get_domain_url(page_url_data)
26862723
unittest.TestCase.maxDiff = 1000
26872724
if level == 1 or level == 2 or level == 3:
2688-
self.assert_equal(page_domain, page_data_domain, domain_fail)
2689-
self.assert_equal(level_1, level_1_data, level_1_failure)
2725+
self.assertEqual(page_domain, page_data_domain, domain_fail)
2726+
self.assertEqual(level_1, level_1_data, level_1_failure)
26902727
unittest.TestCase.maxDiff = None
26912728
if level == 2 or level == 3:
2692-
self.assert_equal(level_2, level_2_data, level_2_failure)
2729+
self.assertEqual(level_2, level_2_data, level_2_failure)
26932730
if level == 3:
2694-
self.assert_equal(level_3, level_3_data, level_3_failure)
2731+
self.assertEqual(level_3, level_3_data, level_3_failure)
26952732
if level == 0:
26962733
try:
26972734
unittest.TestCase.maxDiff = 1000
2698-
self.assert_equal(
2735+
self.assertEqual(
26992736
page_domain, page_data_domain, domain_fail)
2700-
self.assert_equal(level_1, level_1_data, level_1_failure)
2737+
self.assertEqual(level_1, level_1_data, level_1_failure)
27012738
unittest.TestCase.maxDiff = None
2702-
self.assert_equal(level_2, level_2_data, level_2_failure)
2703-
self.assert_equal(level_3, level_3_data, level_3_failure)
2739+
self.assertEqual(level_2, level_2_data, level_2_failure)
2740+
self.assertEqual(level_3, level_3_data, level_3_failure)
27042741
except Exception as e:
27052742
print(e) # Level-0 Dry Run (Only print the differences)
27062743

seleniumbase/fixtures/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Underscore:
6161

6262

6363
class Backbone:
64-
VER = "1.3.3"
64+
VER = "1.4.0"
6565
MIN_JS = ("//cdnjs.cloudflare.com/ajax/libs/"
6666
"backbone.js/%s/backbone-min.js" % VER)
6767

@@ -117,7 +117,7 @@ class Shepherd:
117117

118118

119119
class Tether:
120-
VER = "1.4.4"
120+
VER = "1.4.7"
121121
MIN_JS = ("//cdnjs.cloudflare.com/ajax/libs/"
122122
"tether/%s/js/tether.min.js" % VER)
123123

seleniumbase/resources/shepherd/backbone-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seleniumbase/resources/shepherd/tether.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='seleniumbase',
20-
version='1.31.1',
20+
version='1.31.2',
2121
description='Fast, Easy, and Reliable Browser Automation & Testing.',
2222
long_description=long_description,
2323
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)