Skip to content

Commit 66a96d3

Browse files
authored
Merge pull request #801 from seleniumbase/socks5-edge-extensions-and-more
Chrome extensions in Edge, Socks4/5 proxy support, and more
2 parents fcbbb73 + 75361d8 commit 66a96d3

File tree

15 files changed

+229
-47
lines changed

15 files changed

+229
-47
lines changed

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ pip install seleniumbase
111111
112112
COMMANDS:
113113
install [DRIVER] [OPTIONS]
114+
methods (List common Python methods)
114115
options (List common pytest options)
115116
mkdir [DIRECTORY] [OPTIONS]
116117
mkfile [FILE.py] [OPTIONS]
@@ -569,18 +570,26 @@ pytest test_suite.py --alluredir=allure_results
569570
570571
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Using a Proxy Server:</h3>
571572
572-
If you wish to use a proxy server for your browser tests (Chrome and Firefox only), you can add ``--proxy=IP_ADDRESS:PORT`` as an argument on the command-line.
573+
If you wish to use a proxy server for your browser tests (Chromium or Firefox), you can add ``--proxy=IP_ADDRESS:PORT`` as an argument on the command line.
573574
574575
```bash
575576
pytest proxy_test.py --proxy=IP_ADDRESS:PORT
576577
```
577578
578-
If the proxy server that you wish to use requires authentication, you can do the following (Chrome only):
579+
If the proxy server that you wish to use requires authentication, you can do the following (Chromium only):
579580
580581
```bash
581582
pytest proxy_test.py --proxy=USERNAME:PASSWORD@IP_ADDRESS:PORT
582583
```
583584
585+
SeleniumBase also supports SOCKS4 and SOCKS5 proxies:
586+
587+
```bash
588+
pytest proxy_test.py --proxy="socks4://IP_ADDRESS:PORT"
589+
590+
pytest proxy_test.py --proxy="socks5://IP_ADDRESS:PORT"
591+
```
592+
584593
To make things easier, you can add your frequently-used proxies to PROXY_LIST in [proxy_list.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/proxy_list.py), and then use ``--proxy=KEY_FROM_PROXY_LIST`` to use the IP_ADDRESS:PORT of that key.
585594
586595
```bash

examples/offline_examples/test_demo_page.py

+3
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@ def test_demo_page(self):
9797

9898
# Assert exact text
9999
self.assert_exact_text("Demo Page", "h1")
100+
101+
# Highlight a page element (also assert visibility)
102+
self.highlight("h2")

examples/test_demo_site.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ def test_demo_site(self):
9494
# Assert exact text
9595
self.assert_exact_text("Demo Page", "h1")
9696

97+
# Highlight a page element (also assert visibility)
98+
self.highlight("h2")
99+
97100
# Assert no broken links (Can be slow if many links)
98101
# self.assert_no_404_errors()
99102

100103
# Assert no JavaScript errors (Can also detect 404s)
101-
self.assert_no_js_errors()
104+
# self.assert_no_js_errors()

help_docs/customizing_test_runs.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,26 @@ nosetests test_suite.py --report
338338

339339
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Using a Proxy Server:</h3>
340340

341-
If you wish to use a proxy server for your browser tests (Chrome and Firefox only), you can add ``--proxy=IP_ADDRESS:PORT`` as an argument on the command line.
341+
If you wish to use a proxy server for your browser tests (Chromium or Firefox), you can add ``--proxy=IP_ADDRESS:PORT`` as an argument on the command line.
342342

343343
```bash
344344
pytest proxy_test.py --proxy=IP_ADDRESS:PORT
345345
```
346346

347-
If the proxy server that you wish to use requires authentication, you can do the following (Chrome only):
347+
If the proxy server that you wish to use requires authentication, you can do the following (Chromium only):
348348

349349
```bash
350350
pytest proxy_test.py --proxy=USERNAME:PASSWORD@IP_ADDRESS:PORT
351351
```
352352

353+
SeleniumBase also supports SOCKS4 and SOCKS5 proxies:
354+
355+
```bash
356+
pytest proxy_test.py --proxy="socks4://IP_ADDRESS:PORT"
357+
358+
pytest proxy_test.py --proxy="socks5://IP_ADDRESS:PORT"
359+
```
360+
353361
To make things easier, you can add your frequently-used proxies to PROXY_LIST in [proxy_list.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/proxy_list.py), and then use ``--proxy=KEY_FROM_PROXY_LIST`` to use the IP_ADDRESS:PORT of that key.
354362

355363
```bash

mkdocs.yml

+23-15
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,39 @@ docs_dir: "docs"
1313
copyright: Copyright &copy; 2014 - 2021 Michael Mintz
1414
# Extensions
1515
markdown_extensions:
16-
- markdown.extensions.admonition
17-
- markdown.extensions.attr_list
18-
- markdown.extensions.codehilite
19-
- markdown.extensions.meta
20-
- markdown.extensions.def_list
21-
- markdown.extensions.footnotes
22-
- markdown.extensions.toc:
16+
- admonition
17+
- md_in_html
18+
- toc:
2319
permalink: true
20+
- pymdownx.highlight:
21+
linenums: false
22+
- pymdownx.highlight
23+
- pymdownx.superfences
24+
- pymdownx.inlinehilite
25+
- pymdownx.details
26+
- pymdownx.snippets
2427
# Configuration
2528
theme:
2629
name: material
2730
logo: img/grad_logo.png
2831
favicon: img/grad_logo.png
32+
language: en
2933
include_homepage_in_sidebar: true
3034
sticky_navigation: true
31-
language: en
35+
# collapse_navigation: false
36+
# titles_only: false
3237
include_search_page: false
3338
search_index_only: true
3439
static_templates:
3540
- 404.html
3641
features:
37-
- navigation.sections
42+
# - search.highlight
43+
# - toc.integrate
44+
- navigation.indexes
45+
# - navigation.sections
46+
# - navigation.expand
3847
# - navigation.tabs
3948
- navigation.instant
40-
extra:
41-
search:
42-
language: en
4349
palette:
4450
scheme: default
4551
primary: blue
@@ -51,10 +57,12 @@ theme:
5157
logo: img/sb_logo_7.png
5258
# Plugins
5359
plugins:
54-
- search
60+
- search:
61+
separator: '[\s\-]+'
62+
prebuild_index: true
63+
lang: en
5564
- minify:
5665
minify_html: true
57-
minify_js: true
5866
- mkdocs-simple-hooks:
5967
hooks:
6068
on_pre_build: docs.prepare:main
@@ -99,7 +107,7 @@ nav:
99107
- Table of Contents: help_docs/ReadMe.md
100108
- JS Package Manager: help_docs/js_package_manager.md
101109
- Master QA Hybrid Mode: seleniumbase/masterqa/ReadMe.md
102-
- Decorators & Security: seleniumbase/common/ReadMe.md
110+
- Decorators / Security: seleniumbase/common/ReadMe.md
103111
- Desired Capabilities: help_docs/desired_capabilities.md
104112
- Docker Start Guide: integrations/docker/ReadMe.md
105113
- Using Safari Driver: help_docs/using_safari_driver.md

requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pip>=21.0.1;python_version>="3.6"
33
packaging>=20.9
44
setuptools>=44.1.1;python_version<"3.5"
55
setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"
6-
setuptools>=52.0.0;python_version>="3.6"
6+
setuptools>=53.0.0;python_version>="3.6"
77
setuptools-scm>=5.0.1
88
wheel>=0.36.2
99
attrs>=20.3.0
@@ -62,11 +62,11 @@ prompt-toolkit==3.0.14;python_version>="3.6"
6262
ipython==5.10.0;python_version<"3.5"
6363
ipython==6.5.0;python_version>="3.5" and python_version<"3.6"
6464
ipython==7.16.1;python_version>="3.6" and python_version<"3.7"
65-
ipython==7.19.0;python_version>="3.7"
65+
ipython==7.20.0;python_version>="3.7"
6666
colorama==0.4.4
6767
pathlib2==2.3.5;python_version<"3.5"
6868
importlib-metadata==2.0.0;python_version<"3.6"
69-
virtualenv>=20.4.1
69+
virtualenv>=20.4.2
7070
pymysql==0.10.1;python_version<"3.6"
7171
pymysql==1.0.2;python_version>="3.6"
7272
coverage==5.4

seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "1.54.2"
2+
__version__ = "1.55.0"

seleniumbase/config/proxy_list.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
PROXY_LIST = {
2525
"example1": "152.179.12.86:3128", # (Example) - set your own proxy here
26-
"example2": "176.9.79.126:3128", # (Example) - set your own proxy here
26+
"example2": "socks4://50.197.210.138:32100", # (Example)
2727
"proxy1": None,
2828
"proxy2": None,
2929
"proxy3": None,

seleniumbase/console_scripts/ReadMe.md

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Installs the specified webdriver.
3535
(``iedriver`` is required for Internet Explorer automation)
3636
(``operadriver`` is required for Opera Browser automation)
3737

38+
### methods
39+
40+
* Usage:
41+
``sbase methods``
42+
43+
* Output:
44+
Displays common SeleniumBase Python methods.
45+
3846
### options
3947

4048
* Usage:

seleniumbase/console_scripts/run.py

+61-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
88
Examples:
99
sbase install chromedriver
10+
sbase methods
11+
sbase options
1012
sbase mkdir ui_tests
1113
sbase mkfile new_test.py
1214
sbase mkpres new_presentation.py
13-
sbase options
1415
sbase convert webdriver_unittest_file.py
1516
sbase print my_first_test.py -n
1617
sbase translate my_first_test.py --zh -p
@@ -66,6 +67,7 @@ def show_basic_usage():
6667
sc += ("\n")
6768
sc += ("COMMANDS:\n")
6869
sc += (" install [DRIVER] [OPTIONS]\n")
70+
sc += (" methods (List common Python methods)\n")
6971
sc += (" options (List common pytest options)\n")
7072
sc += (" mkdir [DIRECTORY] [OPTIONS]\n")
7173
sc += (" mkfile [FILE.py] [OPTIONS]\n")
@@ -501,6 +503,62 @@ def show_package_location():
501503
print("%s" % location)
502504

503505

506+
def show_methods():
507+
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
508+
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
509+
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
510+
c4 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX
511+
c5 = colorama.Fore.LIGHTRED_EX + colorama.Back.LIGHTGREEN_EX
512+
cr = colorama.Style.RESET_ALL
513+
sc = ("\n " + c2 + " ** " + c3 + " SeleniumBase Python Methods "
514+
"" + c2 + " ** " + cr)
515+
print(sc)
516+
print("")
517+
line = "Here are some common methods that come with SeleniumBase:"
518+
line = c1 + line + cr
519+
print(line)
520+
line = "(Some optional args are not shown here)"
521+
print(line)
522+
print("")
523+
sbm = ""
524+
sbm += ('*.open(url) => Navigate the browser window to the URL.\n')
525+
sbm += ('*.type(selector, text) => Update the field with the text.\n')
526+
sbm += ('*.click(selector) => Click the element with the selector.\n')
527+
sbm += ('*.click_link(link_text) => Click the link containing text.\n')
528+
sbm += ('*.go_back() => Navigate back to the previous URL.\n')
529+
sbm += ('*.select_option_by_text(dropdown_selector, option)\n')
530+
sbm += ('*.hover_and_click(hover_selector, click_selector)\n')
531+
sbm += ('*.drag_and_drop(drag_selector, drop_selector)\n')
532+
sbm += ('*.get_text(selector) => Get the text from the element.\n')
533+
sbm += ('*.get_current_url() => Get the URL of the current page.\n')
534+
sbm += ('*.get_page_source() => Get the HTML of the current page.\n')
535+
sbm += ('*.get_attribute(selector, attribute) => Get element attribute.\n')
536+
sbm += ('*.get_title() => Get the title of the current page.\n')
537+
sbm += ('*.switch_to_frame(frame) => Switch into the iframe container.\n')
538+
sbm += ('*.switch_to_default_content() => Leave the iframe container.\n')
539+
sbm += ('*.open_new_window() => Open a new window in the same browser.\n')
540+
sbm += ('*.switch_to_window(window) => Switch to the browser window.\n')
541+
sbm += ('*.switch_to_default_window() => Switch to the original window.\n')
542+
sbm += ('*.get_new_driver(OPTIONS) => Open a new driver with OPTIONS.\n')
543+
sbm += ('*.switch_to_driver(driver) => Switch to the browser driver.\n')
544+
sbm += ('*.switch_to_default_driver() => Switch to the original driver.\n')
545+
sbm += ('*.is_element_visible(selector) => Return True if item visible.\n')
546+
sbm += ('*.is_text_visible(text) => Return True if text is visible.\n')
547+
sbm += ('*.save_screenshot(name) => Save a screenshot in PNG format.\n')
548+
sbm += ('*.assert_element(selector) => Verify the element is visible.\n')
549+
sbm += ('*.assert_text(text, selector) => Verify text in the element.\n')
550+
sbm += ('*.assert_title(title) => Verify the title of the web page.\n')
551+
sbm += ('*.assert_downloaded_file(file) => Verify file was downloaded.\n')
552+
sbm += ('*.assert_no_404_errors() => Verify there are no broken links.\n')
553+
sbm += ('*.assert_no_js_errors() => Verify there are no JS errors.\n')
554+
sbm = sbm.replace("*.", "self." + c1).replace('(', cr + '(')
555+
sbm = sbm.replace("self.", c2 + "self" + c5 + "." + cr)
556+
sbm = sbm.replace('(', c3 + '(' + c4)
557+
sbm = sbm.replace(')', c3 + ')' + cr)
558+
print(sbm)
559+
print("")
560+
561+
504562
def show_options():
505563
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
506564
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
@@ -739,6 +797,8 @@ def main():
739797
print()
740798
else:
741799
show_basic_usage()
800+
elif command == "methods" or command == "--methods":
801+
show_methods()
742802
elif command == "options" or command == "--options":
743803
show_options()
744804
elif command == "help" or command == "--help":

seleniumbase/console_scripts/sb_mkdir.py

+1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def main():
376376
data.append(' self.assert_link_text("seleniumbase.io")')
377377
data.append(' self.click_link("SeleniumBase Demo Page")')
378378
data.append(' self.assert_exact_text("Demo Page", "h1")')
379+
data.append(' self.highlight("h2")')
379380
data.append("")
380381
file_path = "%s/%s" % (dir_name, "test_demo_site.py")
381382
file = codecs.open(file_path, "w+", "utf-8")

0 commit comments

Comments
 (0)