Skip to content

Commit b1db6cc

Browse files
authored
Merge pull request #334 from seleniumbase/timeout-feature
Timeout feature
2 parents 2ef6788 + f29cd8c commit b1db6cc

File tree

7 files changed

+33
-9
lines changed

7 files changed

+33
-9
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ cd SeleniumBase
3939
pip install -r requirements.txt
4040
python setup.py develop
4141
```
42-
* ("``pip install -e .``" also works from the top-level SeleniumBase folder.)
42+
* "``pip install -e .``" also works from the top-level SeleniumBase folder.
4343

4444
You can also install a specific GitHub branch of SeleniumBase:
4545
```
@@ -52,17 +52,18 @@ SeleniumBase can download a web driver to the [seleniumbase/drivers](https://git
5252
```
5353
seleniumbase install chromedriver
5454
```
55-
* (You need a different web driver for each web browser you want to run automation on: ``chromedriver`` for Chrome, ``edgedriver`` for Edge, ``geckodriver`` for Firefox, ``operadriver`` for Opera, and ``iedriver`` for Internet Explorer.)
55+
* You need a different web driver for each web browser you want to run automation on: ``chromedriver`` for Chrome, ``edgedriver`` for Edge, ``geckodriver`` for Firefox, ``operadriver`` for Opera, and ``iedriver`` for Internet Explorer.
5656

5757
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Run a test on Chrome:
5858
```
5959
cd examples
6060
pytest my_first_test.py --browser=chrome
6161
```
62-
* (Chrome is the default browser if not specified with ``--browser``)
62+
* Chrome is the default browser if not specified with ``--browser=BROWSER``.
63+
* You MUST add ``--headless`` for your tests to run on a headless machine (No GUI). You can also run in headless mode on any machine.
6364

6465
**Check out [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) to see what a simple test looks like:**
65-
* (<i>By default, [CSS Selectors](https://www.w3schools.com/cssref/css_selectors.asp) are used for finding page elements.</i>)
66+
* <i>By default, [CSS Selectors](https://www.w3schools.com/cssref/css_selectors.asp) are used for finding page elements.</i>
6667

6768
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Learn More:
6869

examples/timeout_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
""" This test fails on purpose to demonstrate the timeout feature
2+
for tests that run longer than the time limit specified. """
3+
4+
import pytest
5+
import time
6+
from seleniumbase import BaseCase
7+
8+
9+
class MyTestClass(BaseCase):
10+
11+
@pytest.mark.expected_failure
12+
@pytest.mark.timeout(6) # The test will fail if it runs longer than this
13+
def test_timeout_failure(self):
14+
self.open("https://xkcd.com/1658/")
15+
time.sleep(7)

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ pluggy>=0.12.0
1313
pytest>=4.6.3
1414
pytest-cov>=2.7.1
1515
pytest-forked>=1.0.2
16-
pytest-html>=1.21.0
16+
pytest-html>=1.21.1
1717
pytest-metadata>=1.8.0
1818
pytest-ordering>=0.6
1919
pytest-rerunfailures>=7.0
20+
pytest-timeout>=1.3.3
2021
pytest-xdist>=1.29.0
2122
parameterized>=0.7.0
2223
beautifulsoup4>=4.6.0
@@ -25,5 +26,5 @@ colorama>=0.4.1
2526
pyotp>=2.2.7
2627
boto>=2.49.0
2728
flake8>=3.7.7
28-
certifi>=2019.3.9
29+
certifi>=2019.6.16
2930
PyVirtualDisplay==0.2.1

seleniumbase/console_scripts/sb_install.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import shutil
2020
import sys
2121
import tarfile
22+
import urllib3
2223
import zipfile
2324
from seleniumbase import drivers # webdriver storage folder for SeleniumBase
25+
urllib3.disable_warnings()
2426
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
2527

2628

seleniumbase/core/browser_launcher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
import threading
66
import time
7+
import urllib3
78
import warnings
89
from selenium import webdriver
910
from selenium.common.exceptions import WebDriverException
@@ -17,6 +18,7 @@
1718
from seleniumbase.fixtures import page_utils
1819
from seleniumbase import drivers # webdriver storage folder for SeleniumBase
1920
from seleniumbase import extensions # browser extensions storage folder
21+
urllib3.disable_warnings()
2022
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
2123
EXTENSIONS_DIR = os.path.dirname(os.path.realpath(extensions.__file__))
2224
DISABLE_CSP_ZIP_PATH = "%s/%s" % (EXTENSIONS_DIR, "disable_csp.zip")

seleniumbase/fixtures/base_case.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_anything(self):
3030
import re
3131
import sys
3232
import time
33+
import urllib3
3334
import unittest
3435
import uuid
3536
from selenium.common.exceptions import (StaleElementReferenceException,
@@ -53,6 +54,7 @@ def test_anything(self):
5354
from seleniumbase.fixtures import page_actions
5455
from seleniumbase.fixtures import page_utils
5556
from seleniumbase.fixtures import xpath_to_css
57+
urllib3.disable_warnings()
5658
ENI_Exception = selenium_exceptions.ElementNotInteractableException
5759

5860

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='seleniumbase',
20-
version='1.23.15',
20+
version='1.23.16',
2121
description='Reliable Browser Automation & Testing Framework',
2222
long_description=long_description,
2323
long_description_content_type='text/markdown',
@@ -66,10 +66,11 @@
6666
'pytest>=4.6.3',
6767
'pytest-cov>=2.7.1',
6868
'pytest-forked>=1.0.2',
69-
'pytest-html>=1.21.0',
69+
'pytest-html>=1.21.1',
7070
'pytest-metadata>=1.8.0',
7171
'pytest-ordering>=0.6',
7272
'pytest-rerunfailures>=7.0',
73+
'pytest-timeout>=1.3.3',
7374
'pytest-xdist>=1.29.0',
7475
'parameterized>=0.7.0',
7576
'beautifulsoup4>=4.6.0', # Keep at >=4.6.0 while using "bs4"
@@ -78,7 +79,7 @@
7879
'pyotp>=2.2.7',
7980
'boto>=2.49.0',
8081
'flake8>=3.7.7',
81-
'certifi>=2019.3.9',
82+
'certifi>=2019.6.16',
8283
'PyVirtualDisplay==0.2.1', # Keep at 0.2.1 (later versions are slow)
8384
],
8485
packages=[

0 commit comments

Comments
 (0)