├── .github
├── Workflows.md
└── workflows
│ ├── pages.yml
│ ├── python-nightly-mac.yml
│ ├── python-nightly-ubuntu.yml
│ ├── python-nightly-windows.yml
│ └── python-package.yml
├── .gitignore
├── CHANGELOG.md
├── CNAME
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Dockerfile
├── LICENSE
├── MANIFEST.in
├── README.md
├── SECURITY.md
├── _config.yml
├── azure-pipelines.yml
├── examples
├── ReadMe.md
├── __init__.py
├── basic_test.py
├── behave_bdd
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── behave.ini
│ └── features
│ │ ├── __init__.py
│ │ ├── behave.ini
│ │ ├── calculator.feature
│ │ ├── environment.py
│ │ ├── fail_page.feature
│ │ ├── login_app.feature
│ │ ├── realworld.feature
│ │ ├── steps
│ │ ├── __init__.py
│ │ ├── calculator.py
│ │ ├── fail_page.py
│ │ ├── imported.py
│ │ └── swag_labs.py
│ │ └── swag_labs.feature
├── boilerplates
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── base_test_case.py
│ ├── boilerplate_test.py
│ ├── classic_obj_test.py
│ ├── page_objects.py
│ ├── samples
│ │ ├── __init__.py
│ │ ├── file_parsing
│ │ │ ├── __init__.py
│ │ │ ├── parse_files.py
│ │ │ ├── qa_login_example.txt
│ │ │ └── staging_login_example.txt
│ │ ├── google_objects.py
│ │ ├── google_test.py
│ │ ├── sb_swag_test.py
│ │ ├── swag_labs_test.py
│ │ └── test_page_objects.py
│ └── sb_fixture_test.py
├── capabilities
│ ├── ReadMe.md
│ ├── mac_cap_file.py
│ ├── sample_cap_file_BS.py
│ ├── sample_cap_file_BS.yml
│ ├── sample_cap_file_SL.py
│ ├── selenoid_cap_file.py
│ └── win10_cap_file.py
├── case_plans
│ ├── basic_test.MyTestClass.test_basics.md
│ ├── my_first_test.MyTestClass.test_swag_labs.md
│ ├── shadow_root_test.ShadowRootTest.test_shadow_root.md
│ ├── test_assert_elements.ListAssertTests.test_assert_list_of_elements.md
│ ├── test_calculator.CalculatorTests.test_6_times_7_plus_12_equals_54.md
│ ├── test_demo_site.DemoSiteTests.test_demo_site.md
│ ├── test_login.SwagLabsLoginTests.test_swag_labs_login.md
│ └── test_mfa_login.TestMFALogin.test_mfa_login.md
├── case_summary.md
├── cdp_mode
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── raw_ahrefs.py
│ ├── raw_albertsons.py
│ ├── raw_antibot.py
│ ├── raw_async.py
│ ├── raw_bestwestern.py
│ ├── raw_browserscan.py
│ ├── raw_cdp.py
│ ├── raw_cdp_drivers.py
│ ├── raw_cdp_extended.py
│ ├── raw_cdp_methods.py
│ ├── raw_cdp_nike.py
│ ├── raw_cdp_with_sb.py
│ ├── raw_cf.py
│ ├── raw_chatgpt.py
│ ├── raw_consecutive_c.py
│ ├── raw_cookies_async.py
│ ├── raw_demo_site.py
│ ├── raw_driver.py
│ ├── raw_easyjet.py
│ ├── raw_elal.py
│ ├── raw_fingerprint.py
│ ├── raw_footlocker.py
│ ├── raw_geolocation.py
│ ├── raw_geolocation_sb.py
│ ├── raw_gettyimages.py
│ ├── raw_gitlab.py
│ ├── raw_glassdoor.py
│ ├── raw_handle_alerts.py
│ ├── raw_hyatt.py
│ ├── raw_indeed.py
│ ├── raw_kohls.py
│ ├── raw_multi_async.py
│ ├── raw_multi_cdp.py
│ ├── raw_nike.py
│ ├── raw_nordstrom.py
│ ├── raw_pixelscan.py
│ ├── raw_planetmc.py
│ ├── raw_pokemon.py
│ ├── raw_priceline.py
│ ├── raw_proxy.py
│ ├── raw_publication.py
│ ├── raw_radwell.py
│ ├── raw_req_async.py
│ ├── raw_req_mod.py
│ ├── raw_req_sb.py
│ ├── raw_res_nike.py
│ ├── raw_res_sb.py
│ ├── raw_science.py
│ ├── raw_socialblade.py
│ ├── raw_southwest.py
│ ├── raw_tab_switching.py
│ ├── raw_theaters.py
│ ├── raw_tiktok.py
│ ├── raw_timezone.py
│ ├── raw_timezone_sb.py
│ ├── raw_united.py
│ ├── raw_walmart.py
│ ├── raw_wsform.py
│ ├── raw_xhr_async.py
│ └── raw_xhr_sb.py
├── chart_maker
│ ├── ReadMe.md
│ ├── chart_presentation.py
│ ├── my_chart.py
│ ├── pie_charts.py
│ ├── test_area_chart.py
│ ├── test_display_chart.py
│ ├── test_line_chart.py
│ ├── test_multi_series.py
│ └── test_save_chart.py
├── coffee_cart_tests.py
├── custom_settings.py
├── desktop_apps
│ ├── ReadMe.md
│ └── recorder.py
├── dialog_boxes
│ ├── ReadMe.md
│ └── dialog_box_tour.py
├── edge_test.py
├── example_config.cfg
├── example_logs
│ ├── ReadMe.md
│ ├── basic_test_info.txt
│ ├── page_source.html
│ └── screenshot.png
├── github_test.py
├── gui_test_runner.py
├── hack_the_planet.py
├── handle_alert_test.py
├── iframe_tests.py
├── locale_code_test.py
├── master_qa
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── basic_masterqa_test_0.py
│ ├── masterqa_test_1.py
│ └── pytest.ini
├── migration
│ ├── __init__.py
│ ├── protractor
│ │ ├── ReadMe.md
│ │ ├── __init__.py
│ │ ├── example_spec.js
│ │ ├── example_test.py
│ │ ├── input_spec.js
│ │ ├── input_test.py
│ │ ├── mat_paginator_spec.js
│ │ └── mat_paginator_test.py
│ └── raw_selenium
│ │ ├── ReadMe.md
│ │ ├── __init__.py
│ │ ├── flaky_messy_raw.py
│ │ ├── long_messy_raw.py
│ │ ├── messy_raw.py
│ │ ├── pytest.ini
│ │ ├── refined_raw.py
│ │ └── simple_sbase.py
├── multiple_cdp_drivers.py
├── my_first_test.py
├── nth_child_test.py
├── offline_examples
│ ├── __init__.py
│ ├── demo_page.html
│ ├── load_html_test.py
│ ├── test_demo_page.py
│ ├── test_extended_driver.py
│ ├── test_handle_alerts.py
│ ├── test_request_fixture.py
│ └── test_user_agent.py
├── old_wordle_script.py
├── parameterized_test.py
├── performance_test.py
├── presenter
│ ├── ReadMe.md
│ ├── core_presentation.py
│ ├── edge_presentation.py
│ ├── fundamentals.py
│ ├── hacking_with_cdp.py
│ ├── multi_uc.py
│ ├── my_presentation.py
│ ├── py_virtual_envs.py
│ ├── uc_presentation.py
│ ├── uc_presentation_3.py
│ ├── uc_presentation_4.py
│ └── web_scraping_on_gha.py
├── proxy_test.py
├── pytest.ini
├── rate_limiting_test.py
├── raw_ahrefs.py
├── raw_antibot_login.py
├── raw_bing_captcha.py
├── raw_block.py
├── raw_brotector_captcha.py
├── raw_call.py
├── raw_cdp_drivers.py
├── raw_cdp_logging.py
├── raw_cf.py
├── raw_cookies.py
├── raw_detection.py
├── raw_driver_context.py
├── raw_driver_manager.py
├── raw_file_call.py
├── raw_form_turnstile.py
├── raw_games.py
├── raw_google.py
├── raw_gui_click.py
├── raw_hobbit.py
├── raw_invisible_captcha.py
├── raw_login_context.py
├── raw_login_driver.py
├── raw_login_sb.py
├── raw_main_call.py
├── raw_mobile.py
├── raw_multi_drivers.py
├── raw_nopecha.py
├── raw_order_tickets.py
├── raw_parameter_script.py
├── raw_performance_logs.py
├── raw_pixelscan.py
├── raw_pyautogui.py
├── raw_recaptcha.py
├── raw_robot.py
├── raw_sb.py
├── raw_skype_mobile.py
├── raw_test_scripts.py
├── raw_turnstile.py
├── raw_uc_events.py
├── raw_uc_mode.py
├── sb_fixture_tests.py
├── setup.cfg
├── shadow_root_test.py
├── swag_labs_user_tests.py
├── test_3d_apis.py
├── test_apple_site.py
├── test_assert_elements.py
├── test_calculator.py
├── test_canvas.py
├── test_cdp_ad_blocking.py
├── test_checkboxes.py
├── test_chinese_pdf.py
├── test_chromedriver.py
├── test_coffee_cart.py
├── test_console_logging.py
├── test_contains_selector.py
├── test_cycle_elements.py
├── test_decryption.py
├── test_deferred_asserts.py
├── test_demo_site.py
├── test_detect_404s.py
├── test_docs_site.py
├── test_double_click.py
├── test_download_files.py
├── test_download_images.py
├── test_drag_and_drop.py
├── test_error_page.py
├── test_event_firing.py
├── test_fail.py
├── test_geolocation.py
├── test_get_coffee.py
├── test_get_locale_code.py
├── test_get_pdf_text.py
├── test_get_swag.py
├── test_get_user_agent.py
├── test_hack_search.py
├── test_highlight_elements.py
├── test_image_saving.py
├── test_inspect_html.py
├── test_login.py
├── test_markers.py
├── test_mfa_login.py
├── test_multiple_drivers.py
├── test_null.py
├── test_override_driver.py
├── test_override_sb_fixture.py
├── test_parse_soup.py
├── test_pdf_asserts.py
├── test_pytest_parametrize.py
├── test_repeat_tests.py
├── test_request_sb_fixture.py
├── test_roblox_mobile.py
├── test_save_screenshots.py
├── test_sb_fixture.py
├── test_scrape_bing.py
├── test_select_options.py
├── test_shadow_dom.py
├── test_show_file_choosers.py
├── test_simple_login.py
├── test_suite.py
├── test_swag_labs.py
├── test_tinymce.py
├── test_todomvc.py
├── test_url_asserts.py
├── test_usefixtures.py
├── test_verify_chromedriver.py
├── test_window_switching.py
├── test_xfail.py
├── test_xkcd.py
├── time_limit_test.py
├── tour_examples
│ ├── ReadMe.md
│ ├── bootstrap_google_tour.py
│ ├── bootstrap_xkcd_tour.py
│ ├── driverjs_maps_tour.py
│ ├── google_tour.py
│ ├── hopscotch_google_tour.py
│ ├── introjs_google_tour.py
│ ├── maps_introjs_tour.py
│ ├── octocat_tour.py
│ ├── shepherd_google_tour.py
│ └── xkcd_tour.py
├── translations
│ ├── ReadMe.md
│ ├── chinese_test_1.py
│ ├── dutch_test_1.py
│ ├── english_test_1.py
│ ├── french_test_1.py
│ ├── italian_test_1.py
│ ├── japanese_test_1.py
│ ├── korean_test_1.py
│ ├── portuguese_test_1.py
│ ├── pytest.ini
│ ├── russian_test_1.py
│ └── spanish_test_1.py
├── uc_cdp_events.py
├── unit_tests
│ ├── ReadMe.md
│ └── verify_framework.py
├── upgrade_chromedriver.py
├── upload_file_test.py
├── user_agent_test.py
├── verify_undetected.py
├── visual_testing
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── case_plans
│ │ ├── layout_test.VisualLayoutTests.test_applitools_layout_change.md
│ │ ├── python_home_test.VisualLayoutTests.test_python_home_layout_change.md
│ │ ├── test_layout_fail.VisualLayoutFailureTests.test_applitools_change.md
│ │ ├── test_layout_fail.VisualLayoutFailureTests.test_xkcd_logo_change.md
│ │ ├── test_layout_fail.VisualLayout_FixtureTests.test_python_home_change.md
│ │ └── xkcd_visual_test.VisualLayoutTests.test_xkcd_layout_change.md
│ ├── layout_test.py
│ ├── python_home_test.py
│ ├── test_layout_fail.py
│ └── xkcd_visual_test.py
├── wordle_test.py
├── xpath_test.py
└── youtube_search_test.py
├── help_docs
├── ReadMe.md
├── behave_gui.md
├── case_plans.md
├── chinese.md
├── commander.md
├── customizing_test_runs.md
├── demo_mode.md
├── desired_capabilities.md
├── features_list.md
├── handling_iframes.md
├── happy_customers.md
├── hidden_files_info.md
├── how_it_works.md
├── html_inspector.md
├── install.md
├── install_python_pip_git.md
├── js_package_manager.md
├── locale_codes.md
├── method_summary.md
├── mobile_testing.md
├── mysql_installation.md
├── recorder_mode.md
├── shadow_dom.md
├── syntax_formats.md
├── thank_you.md
├── translations.md
├── uc_mode.md
├── useful_grep_commands.md
├── using_safari_driver.md
├── verify_webdriver.md
├── virtualenv_instructions.md
└── webdriver_installation.md
├── install.sh
├── integrations
├── __init__.py
├── azure
│ ├── azure_pipelines
│ │ └── ReadMe.md
│ └── jenkins
│ │ └── ReadMe.md
├── behave
│ ├── ReadMe.md
│ ├── behave.ini
│ └── features
│ │ ├── __init__.py
│ │ ├── behave.ini
│ │ ├── calculator.feature
│ │ ├── environment.py
│ │ ├── fail_page.feature
│ │ ├── realworld.feature
│ │ ├── steps
│ │ ├── __init__.py
│ │ ├── calculator.py
│ │ ├── fail_page.py
│ │ ├── real_world.py
│ │ └── swag_labs.py
│ │ └── swag_labs.feature
├── brython
│ ├── ReadMe.md
│ ├── index.html
│ ├── index.py
│ └── library.html
├── docker
│ ├── ReadMe.md
│ ├── docker-entrypoint.sh
│ └── run_docker_test_in_chrome.sh
├── github
│ ├── ReadMe.md
│ └── workflows
│ │ ├── ReadMe.md
│ │ └── extras.md
├── google_cloud
│ └── ReadMe.md
├── katalon
│ └── ReadMe.md
├── linux
│ ├── Linuxfile.sh
│ ├── ReadMe.md
│ ├── Xvfb_launcher.sh
│ ├── jenkins_permissions.sh
│ └── tomcat_permissions.sh
├── node_js
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── index.html
│ ├── my_first_test.py
│ ├── npm-shrinkwrap.json
│ ├── package.json
│ ├── server.js
│ └── test_demo_site.py
├── selenium_grid
│ └── ReadMe.md
└── selenium_ide
│ └── ReadMe.md
├── mkdocs.yml
├── mkdocs_build
├── ReadMe.txt
├── docs_instructions.txt
├── img
│ ├── dash_pie.png
│ ├── dash_pie_2.png
│ ├── dash_pie_3.png
│ ├── favicon.ico
│ ├── grad_logo.png
│ ├── green_icon.png
│ ├── green_logo.png
│ ├── green_logo2.png
│ ├── green_logo3.png
│ ├── logo3.png
│ ├── logo3a.png
│ ├── logo3b.png
│ ├── logo3c.png
│ ├── logo4.png
│ ├── logo5.png
│ ├── logo6.png
│ ├── logo7.png
│ ├── sb_icon.png
│ ├── sb_logo_10.png
│ ├── sb_logo_7.png
│ ├── side_by_side.png
│ └── social
│ │ ├── share_facebook.svg
│ │ ├── share_github.svg
│ │ ├── share_gitter.svg
│ │ ├── share_instagram.svg
│ │ └── share_twitter.svg
├── index.txt
├── prepare.py
└── requirements.txt
├── pyproject.toml
├── pytest.ini
├── requirements.txt
├── sbase
├── ReadMe.txt
├── __init__.py
├── __main__.py
└── steps.py
├── seleniumbase
├── ReadMe.md
├── __init__.py
├── __main__.py
├── __version__.py
├── behave
│ ├── __init__.py
│ ├── behave_helper.py
│ ├── behave_sb.py
│ └── steps.py
├── common
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── decorators.py
│ ├── encryption.py
│ ├── exceptions.py
│ ├── obfuscate.py
│ └── unobfuscate.py
├── config
│ ├── __init__.py
│ ├── ad_block_list.py
│ ├── proxy_list.py
│ └── settings.py
├── console_scripts
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── logo_helper.py
│ ├── rich_helper.py
│ ├── run.py
│ ├── sb_behave_gui.py
│ ├── sb_caseplans.py
│ ├── sb_commander.py
│ ├── sb_install.py
│ ├── sb_mkchart.py
│ ├── sb_mkdir.py
│ ├── sb_mkfile.py
│ ├── sb_mkpres.py
│ ├── sb_mkrec.py
│ ├── sb_objectify.py
│ ├── sb_print.py
│ └── sb_recorder.py
├── core
│ ├── __init__.py
│ ├── application_manager.py
│ ├── browser_launcher.py
│ ├── capabilities_parser.py
│ ├── colored_traceback.py
│ ├── create_db_tables.sql
│ ├── detect_b_ver.py
│ ├── download_helper.py
│ ├── encoded_images.py
│ ├── jqc_helper.py
│ ├── log_helper.py
│ ├── mysql.py
│ ├── proxy_helper.py
│ ├── recorder_helper.py
│ ├── report_helper.py
│ ├── s3_manager.py
│ ├── sb_cdp.py
│ ├── sb_driver.py
│ ├── session_helper.py
│ ├── settings_parser.py
│ ├── style_sheet.py
│ ├── testcase_manager.py
│ ├── tour_helper.py
│ └── visual_helper.py
├── drivers
│ ├── ReadMe.md
│ └── __init__.py
├── extensions
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── ad_block.zip
│ ├── disable_csp.zip
│ ├── firefox_addon.xpi
│ ├── recorder.zip
│ └── sbase_ext.zip
├── fixtures
│ ├── __init__.py
│ ├── base_case.py
│ ├── constants.py
│ ├── css_to_xpath.py
│ ├── errors.py
│ ├── js_utils.py
│ ├── page_actions.py
│ ├── page_utils.py
│ ├── shared_utils.py
│ ├── unittest_helper.py
│ ├── words.py
│ └── xpath_to_css.py
├── js_code
│ ├── __init__.py
│ ├── active_css_js.py
│ ├── live_js.py
│ └── recorder_js.py
├── masterqa
│ ├── ReadMe.md
│ ├── __init__.py
│ └── master_qa.py
├── plugins
│ ├── __init__.py
│ ├── base_plugin.py
│ ├── basic_test_info.py
│ ├── db_reporting_plugin.py
│ ├── driver_manager.py
│ ├── page_source.py
│ ├── pytest_plugin.py
│ ├── s3_logging_plugin.py
│ ├── sb_manager.py
│ ├── screen_shots.py
│ └── selenium_plugin.py
├── resources
│ ├── ReadMe.md
│ ├── __init__.py
│ └── favicon.ico
├── translate
│ ├── __init__.py
│ ├── chinese.py
│ ├── dutch.py
│ ├── french.py
│ ├── italian.py
│ ├── japanese.py
│ ├── korean.py
│ ├── master_dict.py
│ ├── portuguese.py
│ ├── russian.py
│ ├── spanish.py
│ └── translator.py
├── undetected
│ ├── __init__.py
│ ├── cdp.py
│ ├── cdp_driver
│ │ ├── __init__.py
│ │ ├── _contradict.py
│ │ ├── browser.py
│ │ ├── cdp_util.py
│ │ ├── config.py
│ │ ├── connection.py
│ │ ├── element.py
│ │ └── tab.py
│ ├── dprocess.py
│ ├── options.py
│ ├── patcher.py
│ ├── reactor.py
│ └── webelement.py
└── utilities
│ ├── __init__.py
│ ├── selenium_grid
│ ├── ReadMe.md
│ ├── __init__.py
│ ├── download_selenium_server.py
│ ├── font_color
│ ├── grid-hub
│ ├── grid-node
│ ├── grid_hub.py
│ ├── grid_node.py
│ ├── register-grid-node.bat
│ ├── register-grid-node.sh
│ ├── start-grid-hub.bat
│ └── start-grid-hub.sh
│ └── selenium_ide
│ ├── ReadMe.md
│ ├── __init__.py
│ └── convert_ide.py
├── setup.cfg
├── setup.py
├── virtualenv_install.sh
├── win_install.bat
└── win_virtualenv.bat
/.github/Workflows.md:
--------------------------------------------------------------------------------
1 | ### SeleniumBase Workflows
2 |
3 | > **Table of Contents / Navigation:**
4 | > - [**CI build**](workflows/python-package.yml)
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
CHANGELOG
2 |
3 | ## See: [SeleniumBase/releases](https://github.com/seleniumbase/SeleniumBase/releases) 🗂️ 📋
4 |
5 | ### (For CDP updates, see the [CDP Mode docs](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/ReadMe.md))
6 |
--------------------------------------------------------------------------------
/CNAME:
--------------------------------------------------------------------------------
1 | seleniumbase.dev
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2025 Michael Mintz
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include README.md
2 | include pytest.ini
3 | include setup.cfg
4 | include .gitignore
5 | include requirements.txt
6 | include install.sh
7 | include install.bat
8 | include virtualenv_install.sh
9 | include virtualenv_install.bat
10 | include seleniumbase/core/create_db_tables.sql
11 | include seleniumbase/extensions/*.zip
12 | include seleniumbase/utilities/selenium_grid/grid-hub
13 | include seleniumbase/utilities/selenium_grid/grid-node
14 | include seleniumbase/utilities/selenium_grid/font_color
15 | include seleniumbase/utilities/selenium_grid/start-grid-hub.bat
16 | include seleniumbase/utilities/selenium_grid/register-grid-node.bat
17 | include seleniumbase/utilities/selenium_grid/start-grid-hub.sh
18 | include seleniumbase/utilities/selenium_grid/register-grid-node.sh
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Reporting a Vulnerability
4 |
5 | If you've found a security vulnerability in SeleniumBase, (or a dependency we use), please open an issue.
6 |
7 | [github.com/seleniumbase/SeleniumBase/issues](https://github.com/seleniumbase/SeleniumBase/issues)
8 |
9 | Please describe the results you're seeing, and the results you're expecting.
10 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
2 | title: SeleniumBase
3 | description: Reliable Browser Automation & Testing
--------------------------------------------------------------------------------
/examples/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/__init__.py
--------------------------------------------------------------------------------
/examples/basic_test.py:
--------------------------------------------------------------------------------
1 | """Add an item to a shopping cart. Verify. Remove item. Verify."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class MyTestClass(BaseCase):
7 | def test_basics(self):
8 | self.open("https://www.saucedemo.com")
9 | self.type("#user-name", "standard_user")
10 | self.type("#password", "secret_sauce\n")
11 | self.assert_element("div.inventory_list")
12 | self.assert_exact_text("Products", "span.title")
13 | self.click('button[name*="backpack"]')
14 | self.click("#shopping_cart_container a")
15 | self.assert_exact_text("Your Cart", "span.title")
16 | self.assert_text("Backpack", "div.cart_item")
17 | self.click('button:contains("Remove")') # HTML innerText
18 | self.assert_text_not_visible("Backpack", "div.cart_item")
19 | self.js_click("a#logout_sidebar_link")
20 | self.assert_element("div#login_button_container")
21 |
--------------------------------------------------------------------------------
/examples/behave_bdd/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/behave_bdd/__init__.py
--------------------------------------------------------------------------------
/examples/behave_bdd/behave.ini:
--------------------------------------------------------------------------------
1 | [behave]
2 | show_skipped=false
3 | show_timings=false
4 |
--------------------------------------------------------------------------------
/examples/behave_bdd/features/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/behave_bdd/features/__init__.py
--------------------------------------------------------------------------------
/examples/behave_bdd/features/behave.ini:
--------------------------------------------------------------------------------
1 | [behave]
2 | show_skipped=false
3 | show_timings=false
4 |
--------------------------------------------------------------------------------
/examples/behave_bdd/features/environment.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | from seleniumbase.behave import behave_sb
3 | behave_sb.set_base_class(BaseCase) # Accepts a BaseCase subclass
4 | from seleniumbase.behave.behave_sb import before_all # noqa
5 | from seleniumbase.behave.behave_sb import before_feature # noqa
6 | from seleniumbase.behave.behave_sb import before_scenario # noqa
7 | from seleniumbase.behave.behave_sb import before_step # noqa
8 | from seleniumbase.behave.behave_sb import after_step # noqa
9 | from seleniumbase.behave.behave_sb import after_scenario # noqa
10 | from seleniumbase.behave.behave_sb import after_feature # noqa
11 | from seleniumbase.behave.behave_sb import after_all # noqa
12 |
--------------------------------------------------------------------------------
/examples/behave_bdd/features/fail_page.feature:
--------------------------------------------------------------------------------
1 | Feature: SeleniumBase scenarios for the Fail Page
2 |
3 | Scenario: Fail test on purpose to see what happens
4 | When Open the Fail Page
5 | Then Fail test on purpose
6 |
--------------------------------------------------------------------------------
/examples/behave_bdd/features/login_app.feature:
--------------------------------------------------------------------------------
1 | Feature: SeleniumBase scenarios for the Simple App
2 |
3 | Scenario: Verify the Simple App (Login / Logout)
4 | Given Open "seleniumbase.io/simple/login"
5 | And Type "demo_user" into "#username"
6 | And Type "secret_pass" into "#password"
7 | And Click 'a:contains("Sign in")'
8 | And Assert exact text "Welcome!" in "h1"
9 | And Assert element "img#image1"
10 | And Highlight "#image1"
11 | And Click link "Sign out"
12 | And Assert text "signed out" in "#top_message"
13 |
--------------------------------------------------------------------------------
/examples/behave_bdd/features/realworld.feature:
--------------------------------------------------------------------------------
1 | Feature: SeleniumBase scenarios for the RealWorld App
2 |
3 | Scenario: Verify RealWorld App (log in / sign out)
4 | Given Open "seleniumbase.io/realworld/login"
5 | And Clear Session Storage
6 | When Type "demo_user" into "#username"
7 | And Type "secret_pass" into "#password"
8 | And Do MFA "GAXG2MTEOR3DMMDG" into "#totpcode"
9 | Then Assert exact text "Welcome!" in "h1"
10 | And Highlight "img#image1"
11 | And Click 'a:contains("This Page")'
12 | And Save screenshot to logs
13 | When Click link "Sign out"
14 | Then Assert element 'a:contains("Sign in")'
15 | And Assert text "You have been signed out!"
16 |
--------------------------------------------------------------------------------
/examples/behave_bdd/features/steps/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/behave_bdd/features/steps/__init__.py
--------------------------------------------------------------------------------
/examples/behave_bdd/features/steps/fail_page.py:
--------------------------------------------------------------------------------
1 | from behave import step
2 |
3 |
4 | @step("Open the Fail Page")
5 | def go_to_error_page(context):
6 | context.sb.open("https://seleniumbase.io/error_page/")
7 |
8 |
9 | @step("Fail test on purpose")
10 | def fail_on_purpose(context):
11 | context.sb.fail("This test fails on purpose!")
12 |
--------------------------------------------------------------------------------
/examples/behave_bdd/features/steps/imported.py:
--------------------------------------------------------------------------------
1 | from seleniumbase.behave import steps # noqa
2 |
--------------------------------------------------------------------------------
/examples/boilerplates/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/boilerplates/__init__.py
--------------------------------------------------------------------------------
/examples/boilerplates/boilerplate_test.py:
--------------------------------------------------------------------------------
1 | try: # Run with "pytest" (relative imports are valid)
2 | from .base_test_case import BaseTestCase
3 | from .page_objects import Page
4 | except (ImportError, ValueError): # Run with "python"
5 | from base_test_case import BaseTestCase
6 | from page_objects import Page
7 | BaseTestCase.main(__name__, __file__)
8 |
9 |
10 | class MyTestClass(BaseTestCase):
11 | def test_boilerplate(self):
12 | self.login()
13 | self.example_method()
14 | self.assert_element(Page.html)
15 |
--------------------------------------------------------------------------------
/examples/boilerplates/classic_obj_test.py:
--------------------------------------------------------------------------------
1 | """Classic Page Object Model with BaseCase inheritance."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class DataPage:
7 | def go_to_data_url(self, sb):
8 | sb.open("data:text/html,Hello!
")
9 |
10 | def add_input_text(self, sb, text):
11 | sb.type("input", text)
12 |
13 |
14 | class ObjTests(BaseCase):
15 | def test_data_url_page(self):
16 | DataPage().go_to_data_url(self)
17 | self.assert_text("Hello!", "p")
18 | DataPage().add_input_text(self, "Goodbye!")
19 |
--------------------------------------------------------------------------------
/examples/boilerplates/samples/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/boilerplates/samples/__init__.py
--------------------------------------------------------------------------------
/examples/boilerplates/samples/file_parsing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/boilerplates/samples/file_parsing/__init__.py
--------------------------------------------------------------------------------
/examples/boilerplates/samples/file_parsing/qa_login_example.txt:
--------------------------------------------------------------------------------
1 | admin,admin_username_qa,admin_password_qa
2 | employee,employee_username_qa,employee_password_qa
3 | customer,customer_username_qa,customer_password_qa
--------------------------------------------------------------------------------
/examples/boilerplates/samples/file_parsing/staging_login_example.txt:
--------------------------------------------------------------------------------
1 | admin,admin_username_staging,admin_password_staging
2 | employee,employee_username_staging,employee_password_staging
3 | customer,customer_username_staging,customer_password_staging
--------------------------------------------------------------------------------
/examples/boilerplates/samples/google_objects.py:
--------------------------------------------------------------------------------
1 | """google.com page objects"""
2 |
3 |
4 | class HomePage(object):
5 | dialog_box = '[role="dialog"] div'
6 | search_box = '[title="Search"]'
7 | search_button = 'input[value="Google Search"]'
8 | feeling_lucky_button = """input[value="I'm Feeling Lucky"]"""
9 |
10 |
11 | class ResultsPage(object):
12 | search_results = "div#center_col"
13 |
--------------------------------------------------------------------------------
/examples/boilerplates/samples/sb_swag_test.py:
--------------------------------------------------------------------------------
1 | """Classic Page Object Model with the "sb" fixture."""
2 |
3 |
4 | class LoginPage:
5 | def login_to_swag_labs(self, sb, username):
6 | sb.open("https://www.saucedemo.com")
7 | sb.type("#user-name", username)
8 | sb.type("#password", "secret_sauce")
9 | sb.click('input[type="submit"]')
10 |
11 |
12 | class MyTests:
13 | def test_swag_labs_login(self, sb):
14 | LoginPage().login_to_swag_labs(sb, "standard_user")
15 | sb.assert_element("div.inventory_list")
16 | sb.assert_element('div:contains("Sauce Labs Backpack")')
17 | sb.js_click("a#logout_sidebar_link")
18 | sb.assert_element("div#login_button_container")
19 |
--------------------------------------------------------------------------------
/examples/boilerplates/samples/swag_labs_test.py:
--------------------------------------------------------------------------------
1 | """Classic Page Object Model with BaseCase inheritance."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class LoginPage:
7 | def login_to_swag_labs(self, sb, username):
8 | sb.open("https://www.saucedemo.com")
9 | sb.type("#user-name", username)
10 | sb.type("#password", "secret_sauce")
11 | sb.click('input[type="submit"]')
12 |
13 |
14 | class MyTests(BaseCase):
15 | def test_swag_labs_login(self):
16 | LoginPage().login_to_swag_labs(self, "standard_user")
17 | self.assert_element("div.inventory_list")
18 | self.assert_element('div:contains("Sauce Labs Backpack")')
19 | self.js_click("a#logout_sidebar_link")
20 | self.assert_element("div#login_button_container")
21 |
--------------------------------------------------------------------------------
/examples/boilerplates/sb_fixture_test.py:
--------------------------------------------------------------------------------
1 | """Classic Page Object Model with the "sb" fixture."""
2 |
3 |
4 | class DataPage:
5 | def go_to_data_url(self, sb):
6 | sb.open("data:text/html,Hello!
")
7 |
8 | def add_input_text(self, sb, text):
9 | sb.type("input", text)
10 |
11 |
12 | class ObjTests:
13 | def test_data_url_page(self, sb):
14 | DataPage().go_to_data_url(sb)
15 | sb.assert_text("Hello!", "p")
16 | DataPage().add_input_text(sb, "Goodbye!")
17 |
--------------------------------------------------------------------------------
/examples/capabilities/mac_cap_file.py:
--------------------------------------------------------------------------------
1 | # Desired capabilities example file for generic macOS Grid nodes
2 |
3 | capabilities = {
4 | "platformName": "MAC",
5 | "browserVersion": "latest",
6 | }
7 |
--------------------------------------------------------------------------------
/examples/capabilities/sample_cap_file_BS.py:
--------------------------------------------------------------------------------
1 | # Desired capabilities example .py file for BrowserStack:
2 | # https://www.browserstack.com/docs/automate/capabilities
3 | desired_cap = {
4 | "browser": "Chrome",
5 | "os": "Windows",
6 | "os_version": "11",
7 | "browser_version": "latest",
8 | "browserstack.console": "info",
9 | "browserstack.debug": "true",
10 | "browserstack.networkLogs": "true",
11 | "browserstack.local": "true",
12 | }
13 |
--------------------------------------------------------------------------------
/examples/capabilities/sample_cap_file_BS.yml:
--------------------------------------------------------------------------------
1 | # Desired capabilities example YML file for BrowserStack:
2 | # https://www.browserstack.com/docs/automate/capabilities
3 | platforms:
4 | - browserName: safari
5 | osVersion: 17
6 | deviceName: iPhone 15 Pro Max
7 | buildIdentifier: ${BUILD_NUMBER}
8 | parallelsPerPlatform: 1
9 | projectName: My Project
10 | browserstackLocal: true
11 | debug: true
12 | networkLogs: true
13 |
--------------------------------------------------------------------------------
/examples/capabilities/sample_cap_file_SL.py:
--------------------------------------------------------------------------------
1 | # Desired capabilities example file for Sauce Labs
2 | # Generate from https://saucelabs.com/products/platform-configurator
3 | capabilities = {
4 | "browserName": "chrome",
5 | "browserVersion": "latest",
6 | "platformName": "macOS 10.14",
7 | "sauce:options": {},
8 | }
9 |
--------------------------------------------------------------------------------
/examples/capabilities/selenoid_cap_file.py:
--------------------------------------------------------------------------------
1 | # Desired capabilities example file for Selenoid Grid
2 | #
3 | # The same result can be achieved on the command-line. Eg:
4 | # --cap-string='{"selenoid:options": {"enableVNC": true}}'
5 |
6 | capabilities = {
7 | "acceptSslCerts": True,
8 | "acceptInsecureCerts": True,
9 | "screenResolution": "1920x1080x24",
10 | "selenoid:options": {
11 | "enableVNC": True,
12 | "enableVideo": False,
13 | },
14 | }
15 |
--------------------------------------------------------------------------------
/examples/capabilities/win10_cap_file.py:
--------------------------------------------------------------------------------
1 | # Desired capabilities example file for Windows 10 Grid nodes
2 |
3 | capabilities = {
4 | "platformName": "WIN10",
5 | "browserVersion": "latest",
6 | }
7 |
--------------------------------------------------------------------------------
/examples/case_plans/basic_test.MyTestClass.test_basics.md:
--------------------------------------------------------------------------------
1 | ``basic_test.py::MyTestClass::test_basics``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Log in to https://www.saucedemo.com with ``standard_user``. | Login was successful. |
6 | | 2 | Click on the ``Backpack`` ``ADD TO CART`` button. | The button text changed to ``REMOVE``. |
7 | | 3 | Click on the cart icon. | The ``Backpack`` is seen in the cart. |
8 | | 4 | Remove the ``Backpack`` from the cart. | The ``Backpack`` is no longer in the cart. |
9 | | 5 | Log out from the website. | Logout was successful. |
10 |
--------------------------------------------------------------------------------
/examples/case_plans/my_first_test.MyTestClass.test_swag_labs.md:
--------------------------------------------------------------------------------
1 | ``my_first_test.py::MyTestClass::test_swag_labs``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Log in to https://www.saucedemo.com with ``standard_user``. | Login was successful. |
6 | | 2 | Click on the ``Backpack`` ``ADD TO CART`` button. | The button text changed to ``REMOVE``. |
7 | | 3 | Click on the cart icon. | The ``Backpack`` is seen in the cart. |
8 | | 4 | Click on the ``CHECKOUT`` button. Enter user details and click ``CONTINUE``. | The ``Backpack`` is seen in the cart on the ``CHECKOUT: OVERVIEW`` page. |
9 | | 5 | Click on the ``FINISH`` button. | There is a ``Thank you`` message. |
10 | | 6 | Log out from the website. | Logout was successful. |
11 |
--------------------------------------------------------------------------------
/examples/case_plans/shadow_root_test.ShadowRootTest.test_shadow_root.md:
--------------------------------------------------------------------------------
1 | ``shadow_root_test.py::ShadowRootTest::test_shadow_root``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://seleniumbase.io/other/shadow_dom. Click each tab and verify the text contained within the Shadow Root sections. | Tab 1 text: ``Content Panel 1`` Tab 2 text: ``Content Panel 2`` Tab 3 text: ``Content Panel 3`` |
6 |
--------------------------------------------------------------------------------
/examples/case_plans/test_assert_elements.ListAssertTests.test_assert_list_of_elements.md:
--------------------------------------------------------------------------------
1 | ``test_assert_elements.py::ListAssertTests::test_assert_list_of_elements``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://seleniumbase.io/demo_page. | |
6 | | 2 | Use ``self.assert_elements_present("head", "style", "script")`` to verify that multiple elements are present in the HTML. | The assertion is successful. |
7 | | 3 | Use ``self.assert_elements("h1", "h2", "h3")`` to verify that multiple elements are visible. | The assertion is successful. |
8 | | 4 | Use ``self.assert_elements(["#myDropdown", "#myButton", "#svgRect"])`` to verify that multiple elements are visible. | The assertion is successful. |
9 |
--------------------------------------------------------------------------------
/examples/case_plans/test_calculator.CalculatorTests.test_6_times_7_plus_12_equals_54.md:
--------------------------------------------------------------------------------
1 | ``test_calculator.py::CalculatorTests::test_6_times_7_plus_12_equals_54``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://seleniumbase.io/apps/calculator. Perform the following calculation: ``6 × 7 + 12`` | The output is ``54`` after pressing ``=`` |
6 |
--------------------------------------------------------------------------------
/examples/case_plans/test_login.SwagLabsLoginTests.test_swag_labs_login.md:
--------------------------------------------------------------------------------
1 | ``test_login.py::SwagLabsLoginTests::test_swag_labs_login``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Log in to https://www.saucedemo.com with ``standard_user``. | Login was successful. |
6 | | 2 | Log out from the website. | Logout was successful. |
7 |
--------------------------------------------------------------------------------
/examples/case_plans/test_mfa_login.TestMFALogin.test_mfa_login.md:
--------------------------------------------------------------------------------
1 | ``test_mfa_login.py::TestMFALogin::test_mfa_login``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://seleniumbase.io/realworld/login Enter credentials and Sign In. | Sign In was successful. |
6 | | 2 | Click the ``This Page`` button. Save a screenshot to the logs. | |
7 | | 3 | Click to Sign Out | Sign Out was successful. |
8 |
--------------------------------------------------------------------------------
/examples/cdp_mode/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/cdp_mode/__init__.py
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_ahrefs.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, incognito=True, locale="en") as sb:
4 | url = "https://ahrefs.com/website-authority-checker"
5 | input_field = 'input[placeholder="Enter domain"]'
6 | submit_button = 'span:contains("Check Authority")'
7 | sb.activate_cdp_mode(url) # The bot-check is later
8 | sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
9 | sb.cdp.scroll_down(36)
10 | sb.click(submit_button)
11 | sb.uc_gui_click_captcha()
12 | sb.wait_for_text_not_visible("Checking", timeout=15)
13 | sb.click_if_visible('button[data-cky-tag="close-button"]')
14 | sb.highlight('p:contains("github.com/seleniumbase/SeleniumBase")')
15 | sb.highlight('a:contains("Top 100 backlinks")')
16 | sb.set_messenger_theme(location="bottom_center")
17 | sb.post_message("SeleniumBase wasn't detected!")
18 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_antibot.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | url = "https://seleniumbase.io/antibot/login"
5 | sb.activate_cdp_mode(url)
6 | sb.press_keys("input#username", "demo_user")
7 | sb.press_keys("input#password", "secret_pass")
8 | x, y = sb.cdp.get_gui_element_center("button#myButton")
9 | sb.uc_gui_click_x_y(x, y)
10 | sb.sleep(1.5)
11 | x, y = sb.cdp.get_gui_element_center("a#log-in")
12 | sb.uc_gui_click_x_y(x, y)
13 | sb.assert_text("Welcome!", "h1")
14 | sb.set_messenger_theme(location="bottom_center")
15 | sb.post_message("SeleniumBase wasn't detected!")
16 | sb.sleep(1.5)
17 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_browserscan.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, ad_block=True) as sb:
4 | url = "https://www.browserscan.net/bot-detection"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(1)
7 | sb.cdp.flash("Test Results", duration=4)
8 | sb.sleep(1)
9 | sb.cdp.assert_element('strong:contains("Normal")')
10 | sb.cdp.flash('strong:contains("Normal")', duration=4, pause=4)
11 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_cdp_drivers.py:
--------------------------------------------------------------------------------
1 | # An example of switching between multiple drivers
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True) as sb:
5 | url1 = "https://seleniumbase.io/antibot/login"
6 | sb.activate_cdp_mode(url1)
7 | url2 = "https://seleniumbase.io/hobbit/login"
8 | driver2 = sb.get_new_driver(undetectable=True)
9 | sb.activate_cdp_mode(url2)
10 | sb.sleep(1)
11 | sb.switch_to_default_driver()
12 | sb.assert_url_contains("antibot")
13 | print(sb.get_current_url())
14 | sb.type("input#username", "demo_user")
15 | sb.type("input#password", "secret_pass")
16 | sb.cdp.gui_click_element("button")
17 | sb.sleep(1)
18 | sb.cdp.gui_click_element("a#log-in")
19 | sb.assert_text("Welcome!", "h1")
20 | sb.sleep(2)
21 | sb.switch_to_driver(driver2)
22 | sb.assert_url_contains("hobbit")
23 | print(sb.get_current_url())
24 | sb.cdp.gui_click_element("button")
25 | sb.assert_text("Welcome to Middle Earth!")
26 | sb.click("img")
27 | sb.sleep(3)
28 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_cdp_extended.py:
--------------------------------------------------------------------------------
1 | """The long way of using CDP Mode without WebDriver"""
2 | import asyncio
3 | from seleniumbase import sb_cdp
4 | from seleniumbase import cdp_driver
5 |
6 | url = "https://seleniumbase.io/demo_page"
7 | loop = asyncio.new_event_loop()
8 | driver = cdp_driver.start_sync()
9 | page = loop.run_until_complete(driver.get(url))
10 | sb = sb_cdp.CDPMethods(loop, page, driver)
11 |
12 | sb.press_keys("input", "Text")
13 | sb.highlight("button")
14 | sb.type("textarea", "Here are some words")
15 | sb.click("button")
16 | sb.set_value("input#mySlider", "100")
17 | sb.click_visible_elements("input.checkBoxClassB")
18 | sb.select_option_by_text("#mySelect", "Set to 75%")
19 | sb.gui_hover_and_click("#myDropdown", "#dropOption2")
20 | sb.gui_click_element("#checkBox1")
21 | sb.gui_drag_and_drop("img#logo", "div#drop2")
22 | sb.nested_click("iframe#myFrame3", ".fBox")
23 | sb.sleep(2)
24 | sb.driver.stop()
25 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_cdp_methods.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import sb_cdp
2 |
3 | url = "https://seleniumbase.io/demo_page"
4 | sb = sb_cdp.Chrome(url)
5 | sb.press_keys("input", "Text")
6 | sb.highlight("button")
7 | sb.type("textarea", "Here are some words")
8 | sb.click("button")
9 | sb.set_value("input#mySlider", "100")
10 | sb.click_visible_elements("input.checkBoxClassB")
11 | sb.select_option_by_text("#mySelect", "Set to 75%")
12 | sb.gui_hover_and_click("#myDropdown", "#dropOption2")
13 | sb.gui_click_element("#checkBox1")
14 | sb.gui_drag_and_drop("img#logo", "div#drop2")
15 | sb.nested_click("iframe#myFrame3", ".fBox")
16 | sb.sleep(2)
17 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_cdp_nike.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import sb_cdp
2 |
3 | url = "https://www.nike.com/"
4 | sb = sb_cdp.Chrome(url)
5 | sb.click('div[data-testid="user-tools-container"]')
6 | sb.sleep(1)
7 | search = "Pegasus"
8 | sb.press_keys('input[type="search"]', search)
9 | sb.sleep(4)
10 | elements = sb.select_all('ul[data-testid*="products"] figure .details')
11 | if elements:
12 | print('**** Found results for "%s": ****' % search)
13 | for element in elements:
14 | print("* " + element.text)
15 | sb.driver.stop()
16 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_cdp_with_sb.py:
--------------------------------------------------------------------------------
1 | """Example of using CDP Mode with WebDriver"""
2 | from seleniumbase import SB
3 |
4 |
5 | with SB(uc=True, test=True, locale="en") as sb:
6 | url = "https://www.priceline.com/"
7 | sb.activate_cdp_mode(url)
8 | sb.sleep(2.5)
9 | sb.internalize_links() # Don't open links in a new tab
10 | sb.click("#link_header_nav_experiences")
11 | sb.sleep(3.5)
12 | sb.remove_elements("msm-cookie-banner")
13 | sb.sleep(1.5)
14 | location = "Amsterdam"
15 | where_to = 'div[data-automation*="experiences"] input'
16 | button = 'button[data-automation*="experiences-search"]'
17 | sb.wait_for_text("Where to?")
18 | sb.cdp.gui_click_element(where_to)
19 | sb.press_keys(where_to, location)
20 | sb.sleep(1)
21 | sb.cdp.gui_click_element(button)
22 | sb.sleep(3)
23 | print(sb.get_title())
24 | print("************")
25 | for i in range(8):
26 | sb.cdp.scroll_down(50)
27 | sb.sleep(0.2)
28 | cards = sb.select_all('span[data-automation*="product-list-card"]')
29 | for card in cards:
30 | print("* %s" % card.text)
31 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_cf.py:
--------------------------------------------------------------------------------
1 | """Using CDP Mode with PyAutoGUI to bypass CAPTCHAs."""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True, locale="en", guest=True) as sb:
5 | url = "https://www.cloudflare.com/login"
6 | sb.activate_cdp_mode(url)
7 | sb.sleep(3)
8 | sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar
9 | sb.sleep(2)
10 |
11 | with SB(uc=True, test=True, locale="en", guest=True) as sb:
12 | url = "https://www.cloudflare.com/login"
13 | sb.activate_cdp_mode(url)
14 | sb.sleep(3)
15 | sb.uc_gui_click_captcha() # PyAutoGUI click. (Linux needs it)
16 | sb.sleep(2)
17 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_chatgpt.py:
--------------------------------------------------------------------------------
1 | from contextlib import suppress
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True, ad_block=True) as sb:
5 | url = "https://chatgpt.com/"
6 | sb.activate_cdp_mode(url)
7 | sb.sleep(1)
8 | sb.click_if_visible('button[aria-label="Close dialog"]')
9 | sb.click_if_visible('button[data-testid="close-button"]')
10 | query = "Compare Playwright to SeleniumBase in under 178 words"
11 | sb.press_keys("#prompt-textarea", query)
12 | sb.click('button[data-testid="send-button"]')
13 | print('*** Input for ChatGPT: ***\n"%s"' % query)
14 | sb.sleep(3)
15 | with suppress(Exception):
16 | # The "Stop" button disappears when ChatGPT is done typing a response
17 | sb.wait_for_element_not_visible(
18 | 'button[data-testid="stop-button"]', timeout=20
19 | )
20 | chat = sb.find_element('[data-message-author-role="assistant"] .markdown')
21 | soup = sb.get_beautiful_soup(chat.get_html()).text.strip()
22 | soup = soup.replace("\n\n\n", "\n\n")
23 | print("*** Response from ChatGPT: ***\n%s" % soup)
24 | sb.sleep(3)
25 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_consecutive_c.py:
--------------------------------------------------------------------------------
1 | # An example of bypassing 2 consecutive CF CAPTCHAs"""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True) as sb:
5 | url = "https://sms-man.com/login"
6 | sb.activate_cdp_mode(url)
7 | sb.sleep(2)
8 | sb.uc_gui_click_captcha()
9 | sb.sleep(2)
10 | sb.uc_gui_click_captcha()
11 | sb.sleep(2)
12 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_driver.py:
--------------------------------------------------------------------------------
1 | import atexit
2 | from seleniumbase import Driver
3 |
4 | driver = Driver(uc=True)
5 | atexit.register(driver.quit)
6 | url = "www.planetminecraft.com/account"
7 | driver.uc_activate_cdp_mode(url)
8 | driver.sleep(1)
9 | driver.uc_gui_click_captcha()
10 | driver.sleep(2)
11 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_fingerprint.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | url = "https://demo.fingerprint.com/playground"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(1)
7 | sb.cdp.highlight('a[href*="browser-bot-detection"]')
8 | bot_row_selector = 'table:contains("Bot") tr:nth-of-type(3)'
9 | print(sb.cdp.get_text(bot_row_selector))
10 | sb.cdp.assert_text("Bot Not detected", bot_row_selector)
11 | sb.cdp.highlight(bot_row_selector)
12 | sb.sleep(2)
13 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_footlocker.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
4 | url = "https://www.footlocker.com/"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2.5)
7 | sb.cdp.click_if_visible('button[id*="Agree"]')
8 | sb.sleep(1.5)
9 | sb.cdp.mouse_click('input[aria-label="Search"]')
10 | sb.sleep(1.5)
11 | search = "Nike Shoes"
12 | sb.cdp.press_keys('input[aria-label="Search"]', search)
13 | sb.sleep(2.5)
14 | sb.cdp.mouse_click('ul[id*="typeahead"] li div')
15 | sb.sleep(3.5)
16 | elements = sb.cdp.select_all("a.ProductCard-link")
17 | if elements:
18 | print('**** Found results for "%s": ****' % search)
19 | for element in elements:
20 | print("------------------ >>>")
21 | print("* " + element.text)
22 | sb.sleep(2)
23 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_geolocation.py:
--------------------------------------------------------------------------------
1 | """Geolocation example using CDP Mode without WebDriver"""
2 | from seleniumbase import decorators
3 | from seleniumbase import sb_cdp
4 |
5 |
6 | @decorators.print_runtime("Geolocation CDP Example")
7 | def main():
8 | url = "https://www.openstreetmap.org/"
9 | sb = sb_cdp.Chrome(url, geoloc=(48.87645, 2.26340))
10 | sb.sleep(2)
11 | sb.click('a[aria-label="Show My Location"]')
12 | sb.assert_url_contains("48.876450/2.263400")
13 | sb.sleep(5)
14 | sb.driver.stop()
15 |
16 |
17 | if __name__ == "__main__":
18 | main()
19 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_geolocation_sb.py:
--------------------------------------------------------------------------------
1 | """Geolocation example with CDP Mode"""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True) as sb:
5 | url = "https://www.openstreetmap.org/"
6 | sb.activate_cdp_mode(url, geoloc=(31.774390, 35.222450))
7 | sb.click('a[aria-label="Show My Location"]')
8 | sb.assert_url_contains("31.774390/35.222450")
9 | sb.sleep(5)
10 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_gettyimages.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en", pls="none") as sb:
4 | sb.activate_cdp_mode("https://www.gettyimages.com/")
5 | sb.cdp.click('label:contains("Editorial")')
6 | sb.cdp.press_keys("form input", "comic con 2024 sci fi panel\n")
7 | sb.sleep(3)
8 | items = sb.cdp.find_elements("figure picture img")
9 | for item in items:
10 | item.flash(color="44CC88")
11 | sb.sleep(0.08)
12 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_gitlab.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en") as sb:
4 | url = "https://gitlab.com/users/sign_in"
5 | sb.activate_cdp_mode(url)
6 | sb.uc_gui_click_captcha()
7 | sb.assert_text("Username", '[for="user_login"]', timeout=3)
8 | sb.assert_element('label[for="user_login"]')
9 | sb.highlight('button:contains("Sign in")')
10 | sb.highlight('h1:contains("GitLab.com")')
11 | sb.post_message("SeleniumBase wasn't detected", duration=4)
12 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_glassdoor.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, ad_block=True) as sb:
4 | url = "https://www.glassdoor.com/Reviews/index.htm"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2)
7 | sb.uc_gui_click_captcha()
8 | sb.highlight('[data-test="global-nav-glassdoor-logo"]')
9 | sb.highlight('[data-test="site-header-companies"]')
10 | sb.highlight('[data-test="search-button"]')
11 | sb.highlight('[data-test="sign-in-button"]')
12 | sb.highlight('[data-test="company-search-autocomplete"]')
13 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_handle_alerts.py:
--------------------------------------------------------------------------------
1 | """To handle alerts in CDP Mode, reconnect and use WebDriver."""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True) as sb:
5 | url = "https://the-internet.herokuapp.com/javascript_alerts"
6 | sb.activate_cdp_mode(url)
7 | sb.reconnect()
8 | sb.cdp.gui_click_element('button[onclick="jsAlert()"]')
9 | sb.sleep(1)
10 | sb.accept_alert()
11 | sb.sleep(1)
12 | sb.cdp.gui_click_element('button[onclick="jsConfirm()"]')
13 | sb.sleep(1)
14 | sb.dismiss_alert()
15 | sb.sleep(1)
16 | sb.cdp.gui_click_element('button[onclick="jsPrompt()"]')
17 | sb.sleep(1)
18 | sb.uc_gui_write("Here is my prompt answer\n")
19 | sb.sleep(1)
20 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_indeed.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | url = "https://www.indeed.com/companies/search"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2)
7 | sb.uc_gui_click_captcha()
8 | sb.sleep(1)
9 | company = "NASA Jet Propulsion Laboratory"
10 | sb.press_keys('input[data-testid="company-search-box"]', company)
11 | sb.click('button[type="submit"]')
12 | sb.click('a:contains("%s")' % company)
13 | sb.sleep(3)
14 | sb.cdp.highlight('div[itemprop="name"]')
15 | sb.sleep(1)
16 | sb.cdp.highlight('h2:contains("About the company")')
17 | sb.sleep(2)
18 | for i in range(10):
19 | sb.cdp.scroll_down(12)
20 | sb.sleep(0.14)
21 | info = sb.find_element('[data-testid="AboutSection-section"]')
22 | soup = sb.get_beautiful_soup(info.get_html()).get_text("\n").strip()
23 | print("*** %s: ***\n%s" % (company, soup.replace("\n:", ":")))
24 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_kohls.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
4 | url = "https://www.kohls.com/"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2.5)
7 | search = "Mickey Mouse 100 friends teal pillow"
8 | required_text = "Mickey"
9 | sb.cdp.press_keys('input[name="search"]', search + "\n")
10 | sb.sleep(5)
11 | for item in sb.cdp.find_elements("div.products-container-right"):
12 | if "Sponsored" in item.text:
13 | item.remove_from_dom()
14 | sb.cdp.remove_elements("#tce-sticky-wrapper")
15 | sb.cdp.remove_elements("li.sponsored-product")
16 | sb.cdp.remove_elements("#tce-dec-ces-3-banner")
17 | print('*** Kohls Search for "%s":' % search)
18 | for item in sb.cdp.find_elements("ul.products a img"):
19 | if item:
20 | item.flash(color="44CC88")
21 | title = item.get_attribute("title")
22 | if title and required_text in title:
23 | print("* " + title)
24 | sb.sleep(0.1)
25 | sb.sleep(1)
26 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_multi_async.py:
--------------------------------------------------------------------------------
1 | # Testing multiple CDP drivers using the async API
2 | import asyncio
3 | from concurrent.futures import ThreadPoolExecutor
4 | from random import randint
5 | from seleniumbase import cdp_driver
6 |
7 |
8 | async def main(url):
9 | driver = await cdp_driver.start_async()
10 | page = await driver.get(url)
11 | await page.set_window_rect(randint(4, 600), randint(8, 410), 860, 500)
12 | await page.sleep(0.5)
13 | field = await page.select("input")
14 | await field.send_keys_async("Text")
15 | button = await page.select("button")
16 | await button.click_async()
17 | await page.sleep(2)
18 | driver.stop()
19 |
20 |
21 | def set_up_loop(url):
22 | loop = asyncio.new_event_loop()
23 | loop.run_until_complete(main(url))
24 |
25 |
26 | if __name__ == "__main__":
27 | urls = ["https://seleniumbase.io/demo_page" for i in range(4)]
28 | with ThreadPoolExecutor(max_workers=len(urls)) as executor:
29 | for url in urls:
30 | executor.submit(set_up_loop, url)
31 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_multi_cdp.py:
--------------------------------------------------------------------------------
1 | # Testing multiple CDP drivers using the sync API
2 | from concurrent.futures import ThreadPoolExecutor
3 | from random import randint
4 | from seleniumbase import sb_cdp
5 |
6 |
7 | def main(url):
8 | sb = sb_cdp.Chrome(url)
9 | sb.set_window_rect(randint(4, 720), randint(8, 410), 800, 500)
10 | sb.press_keys("input", "Text")
11 | sb.highlight("button")
12 | sb.click("button")
13 | sb.sleep(2)
14 |
15 |
16 | if __name__ == "__main__":
17 | urls = ["https://seleniumbase.io/demo_page" for i in range(4)]
18 | with ThreadPoolExecutor(max_workers=len(urls)) as executor:
19 | for url in urls:
20 | executor.submit(main, url)
21 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_nike.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en", pls="none") as sb:
4 | url = "https://www.nike.com/"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2.5)
7 | sb.cdp.click('div[data-testid="user-tools-container"]')
8 | sb.sleep(1.5)
9 | search = "Nike Air Force 1"
10 | sb.cdp.press_keys('input[type="search"]', search)
11 | sb.sleep(4)
12 | elements = sb.cdp.select_all('ul[data-testid*="products"] figure .details')
13 | if elements:
14 | print('**** Found results for "%s": ****' % search)
15 | for element in elements:
16 | print("* " + element.text)
17 | sb.sleep(2)
18 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_nordstrom.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en") as sb:
4 | url = "https://www.nordstrom.com/"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2.2)
7 | sb.cdp.click("input#keyword-search-input")
8 | sb.sleep(0.8)
9 | search = "cocktail dresses for women teal"
10 | sb.cdp.press_keys("input#keyword-search-input", search + "\n")
11 | sb.sleep(2.2)
12 | for i in range(16):
13 | sb.cdp.scroll_down(16)
14 | sb.sleep(0.14)
15 | print('*** Nordstrom Search for "%s":' % search)
16 | unique_item_text = []
17 | items = sb.cdp.find_elements("article")
18 | for item in items:
19 | description = item.querySelector("article h3")
20 | if description and description.text not in unique_item_text:
21 | unique_item_text.append(description.text)
22 | price_text = ""
23 | price = item.querySelector('div div span[aria-hidden="true"]')
24 | if price:
25 | price_text = price.text
26 | print("* %s (%s)" % (description.text, price_text))
27 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_pixelscan.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, incognito=True, test=True) as sb:
4 | url = "https://pixelscan.net/fingerprint-check"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(3)
7 | sb.remove_elements(".bg-bannerBg") # Remove top banner
8 | sb.remove_elements("pxlscn-ad1") # Remove an ad banner
9 | sb.remove_elements("pxlscn-ad2") # Remove an ad banner
10 | sb.remove_elements("jdiv") # Remove chat widgets
11 | not_masking_text = "You are not masking your fingerprint"
12 | fp_selector = "pxlscn-fingerprint-masking"
13 | sb.assert_text(not_masking_text, fp_selector, timeout=15)
14 | no_automation_detected = "No automation framework detected"
15 | sb.assert_text(no_automation_detected, "pxlscn-bot-detection")
16 | consistent_selector = 'div.bg-consistentBg [alt="Good"]'
17 | sb.highlight(consistent_selector, loops=8)
18 | sb.sleep(1)
19 | fingerprint_masking_div = "pxlscn-fingerprint-masking div"
20 | sb.highlight(fingerprint_masking_div, loops=9)
21 | sb.sleep(1)
22 | sb.highlight("pxlscn-bot-detection", loops=10)
23 | sb.sleep(2)
24 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_planetmc.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | url = "www.planetminecraft.com/account/sign_in/"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2)
7 | sb.cdp.gui_click_element("#turnstile-widget div")
8 | sb.sleep(2)
9 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_publication.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
4 | url = "https://www.researchgate.net/search/publication"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2)
7 | if sb.cdp.is_element_visible("p.spacer-bottom"):
8 | sb.uc_gui_click_captcha()
9 | shadow_head = "div.main-content div"
10 | if sb.is_element_present(shadow_head):
11 | sb.cdp.gui_click_element(shadow_head)
12 | sb.sleep(1.5)
13 | sb.cdp.click_if_visible('button[aria-label="Close"]')
14 | sb.cdp.remove_elements('div[class*="ad-container"]')
15 | sb.cdp.remove_elements("div.lite-page-ad")
16 | sb.sleep(0.5)
17 | sb.assert_text("Discover the world's scientific knowledge")
18 | sb.highlight('h1[class*="nova"]')
19 | sb.highlight('input[name="q"]')
20 | sb.highlight("a.menu-item.selected")
21 | sb.sleep(1)
22 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_radwell.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en", incognito=True) as sb:
4 | url = "https://www.radwell.com/en-US/Search/Advanced/"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(3)
7 | sb.cdp.press_keys("form#basicsearch input", "821C-PM-111DA-142")
8 | sb.sleep(1)
9 | sb.cdp.click('[value="Search Icon"]')
10 | sb.sleep(3)
11 | sb.cdp.assert_text("MAC VALVES INC", "a.manufacturer-link")
12 | sb.cdp.highlight("a.manufacturer-link")
13 | sb.sleep(1)
14 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_req_mod.py:
--------------------------------------------------------------------------------
1 | """Using CDP.fetch.RequestPaused to modify requests in real-time."""
2 | import mycdp
3 | from seleniumbase import SB
4 |
5 |
6 | async def request_paused_handler(event, tab):
7 | r = event.request
8 | rid = event.request_id
9 | is_image = ".png" in r.url or ".jpg" in r.url or ".gif" in r.url
10 | if not is_image: # Let the data through
11 | tab.feed_cdp(mycdp.fetch.continue_request(request_id=rid))
12 | else: # Modify the data (Change the image URL)
13 | new_url = "https://seleniumbase.io/other/with_frakes.jpg"
14 | tab.feed_cdp(mycdp.fetch.continue_request(request_id=rid, url=new_url))
15 |
16 |
17 | with SB(uc=True, test=True, locale="en", pls="none") as sb:
18 | sb.activate_cdp_mode("about:blank")
19 | sb.cdp.add_handler(mycdp.fetch.RequestPaused, request_paused_handler)
20 | sb.cdp.open("https://gettyimages.com/photos/jonathan-frakes-cast-2022")
21 | new_size = "--width:100;--height:100;"
22 | sb.cdp.set_attributes('[style*="--width:"]', "style", new_size)
23 | sb.sleep(6)
24 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_req_sb.py:
--------------------------------------------------------------------------------
1 | """Using CDP.fetch.RequestPaused to filter content in real-time."""
2 | import colorama
3 | import mycdp
4 | import sys
5 | from seleniumbase import SB
6 |
7 | c1 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
8 | c2 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
9 | cr = colorama.Style.RESET_ALL
10 | if "linux" in sys.platform:
11 | c1 = c2 = cr = ""
12 |
13 |
14 | async def request_paused_handler(event, tab):
15 | r = event.request
16 | is_image = ".png" in r.url or ".jpg" in r.url or ".gif" in r.url
17 | if not is_image: # Let the data through
18 | tab.feed_cdp(mycdp.fetch.continue_request(request_id=event.request_id))
19 | else: # Block the data (images)
20 | TIMED_OUT = mycdp.network.ErrorReason.TIMED_OUT
21 | s = f"{c1}BLOCKING{cr} | {c2}{r.method}{cr} | {r.url}"
22 | print(f" >>> ------------\n{s}")
23 | tab.feed_cdp(mycdp.fetch.fail_request(event.request_id, TIMED_OUT))
24 |
25 |
26 | with SB(uc=True, test=True, locale="en") as sb:
27 | sb.activate_cdp_mode("about:blank")
28 | sb.cdp.add_handler(mycdp.fetch.RequestPaused, request_paused_handler)
29 | url = "https://gettyimages.com/photos/firefly-2003-nathan"
30 | sb.cdp.open(url)
31 | sb.sleep(5)
32 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_res_sb.py:
--------------------------------------------------------------------------------
1 | """Using CDP.network.RequestWillBeSent and CDP.network.ResponseReceived."""
2 | import colorama
3 | import mycdp
4 | import sys
5 | from seleniumbase import SB
6 |
7 | c1 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
8 | c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
9 | cr = colorama.Style.RESET_ALL
10 | if "linux" in sys.platform:
11 | c1 = c2 = cr = ""
12 |
13 |
14 | async def send_handler(event: mycdp.network.RequestWillBeSent):
15 | r = event.request
16 | s = f"{r.method} {r.url}"
17 | for k, v in r.headers.items():
18 | s += f"\n\t{k} : {v}"
19 | print(c1 + "*** ==> RequestWillBeSent <== ***" + cr)
20 | print(s)
21 |
22 |
23 | async def receive_handler(event: mycdp.network.ResponseReceived):
24 | print(c2 + "*** ==> ResponseReceived <== ***" + cr)
25 | print(event.response)
26 |
27 |
28 | with SB(uc=True, test=True, locale="en") as sb:
29 | sb.activate_cdp_mode("about:blank")
30 | sb.cdp.add_handler(mycdp.network.RequestWillBeSent, send_handler)
31 | sb.cdp.add_handler(mycdp.network.ResponseReceived, receive_handler)
32 | url = "https://seleniumbase.io/apps/calculator"
33 | sb.cdp.open(url)
34 | sb.sleep(1)
35 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_science.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, incognito=True, test=True) as sb:
4 | url = "https://earth.esa.int/eogateway/search"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(1)
7 | sb.cdp.click_if_visible('button:contains("Accept cookies")')
8 | for i in range(20):
9 | sb.cdp.scroll_to_bottom()
10 | sb.cdp.click_if_visible('button:contains("READ MORE")')
11 | sb.sleep(1)
12 | elements = sb.cdp.find_elements("h4 a span")
13 | for element in elements:
14 | print(element.text)
15 | print("*** Total entries: %s" % len(elements))
16 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_tab_switching.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | sb.activate_cdp_mode()
5 | sb.open("data:text/html,Page A ")
6 | sb.assert_text("Page A")
7 | sb.open_new_tab()
8 | sb.open("data:text/html,Page B ")
9 | sb.assert_text("Page B")
10 | sb.switch_to_tab(0)
11 | sb.assert_text("Page A")
12 | sb.assert_text_not_visible("Page B")
13 | sb.switch_to_tab(1)
14 | sb.assert_text("Page B")
15 | sb.assert_text_not_visible("Page A")
16 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_theaters.py:
--------------------------------------------------------------------------------
1 | """Simple web-scraping example in CDP Mode"""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
5 | url = "https://architectureofcities.com/roman-theaters"
6 | sb.activate_cdp_mode(url)
7 | sb.cdp.click_if_visible("#cn-close-notice")
8 | sb.cdp.click_if_visible('span:contains("Continue")')
9 | sb.sleep(1)
10 | print("*** " + sb.cdp.get_text("h1") + " ***")
11 | for item in sb.cdp.find_elements("h3"):
12 | if item.text and "." in item.text:
13 | item.flash(color="44CC88")
14 | sb.cdp.scroll_down(34)
15 | print("* " + item.text.replace(" ", " "))
16 | sb.sleep(0.15)
17 | sb.sleep(1)
18 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_tiktok.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, incognito=True, ad_block=True) as sb:
4 | url = "https://www.tiktok.com/@startrek?lang=en"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(2.5)
7 | sb.cdp.click_if_visible('button:contains("Refresh")')
8 | sb.sleep(1.5)
9 | print(sb.cdp.get_text('h2[data-e2e="user-bio"]'))
10 | for i in range(54):
11 | sb.cdp.scroll_down(12)
12 | sb.sleep(1)
13 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_timezone.py:
--------------------------------------------------------------------------------
1 | """Timezone example using CDP Mode without WebDriver"""
2 | import mycdp
3 | from seleniumbase import decorators
4 | from seleniumbase import sb_cdp
5 |
6 |
7 | async def request_paused_handler(event, tab):
8 | r = event.request
9 | is_image = ".png" in r.url or ".jpg" in r.url or ".gif" in r.url
10 | if not is_image: # Let the data through
11 | tab.feed_cdp(mycdp.fetch.continue_request(request_id=event.request_id))
12 | else: # Block the data (images)
13 | TIMED_OUT = mycdp.network.ErrorReason.TIMED_OUT
14 | tab.feed_cdp(mycdp.fetch.fail_request(event.request_id, TIMED_OUT))
15 |
16 |
17 | @decorators.print_runtime("Timezone CDP Example")
18 | def main():
19 | url = "https://www.randymajors.org/what-time-zone-am-i-in"
20 | sb = sb_cdp.Chrome(
21 | url,
22 | ad_block=True,
23 | lang="bn",
24 | tzone="Asia/Kolkata",
25 | geoloc=(26.855323, 80.937710)
26 | )
27 | sb.add_handler(mycdp.fetch.RequestPaused, request_paused_handler)
28 | sb.remove_elements("#right-sidebar")
29 | sb.remove_elements('[id*="Footer"]')
30 | sb.sleep(6)
31 | sb.driver.stop()
32 |
33 |
34 | if __name__ == "__main__":
35 | main()
36 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_timezone_sb.py:
--------------------------------------------------------------------------------
1 | """An example of changing settings during CDP Mode"""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True, pls="eager") as sb:
5 | url = "https://www.randymajors.org/what-time-zone-am-i-in"
6 | sb.activate_cdp_mode(url, tzone="Asia/Kolkata", geoloc=(26.863, 80.94))
7 | sb.remove_elements("#right-sidebar")
8 | sb.remove_elements('[id*="Footer"]')
9 | sb.sleep(5)
10 | sb.cdp.open(url, tzone="Asia/Tokyo", geoloc=(35.050681, 136.844728))
11 | sb.remove_elements("#right-sidebar")
12 | sb.remove_elements('[id*="Footer"]')
13 | sb.sleep(5)
14 |
--------------------------------------------------------------------------------
/examples/cdp_mode/raw_wsform.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, locale="en", incognito=True) as sb:
4 | url = "https://wsform.com/demo/"
5 | sb.activate_cdp_mode(url)
6 | sb.scroll_into_view("div.grid")
7 | sb.uc_gui_click_captcha()
8 | sb.sleep(1)
9 |
--------------------------------------------------------------------------------
/examples/chart_maker/my_chart.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyChartMakerClass(BaseCase):
6 | def test_chart_maker(self):
7 | self.create_presentation()
8 | self.create_pie_chart(title="Automated Tests")
9 | self.add_data_point("Passed", 7, color="#95d96f")
10 | self.add_data_point("Untested", 2, color="#eaeaea")
11 | self.add_data_point("Failed", 1, color="#f1888f")
12 | self.add_slide("Pie Chart
" + self.extract_chart())
13 | self.begin_presentation(filename="my_chart.html")
14 |
--------------------------------------------------------------------------------
/examples/chart_maker/test_area_chart.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyChartMakerClass(BaseCase):
6 | def test_area_chart(self):
7 | self.create_presentation(theme="moon")
8 | self.create_area_chart(
9 | title="Time Outside", subtitle="Last Week", unit="Minutes"
10 | )
11 | self.add_data_point("Sun", 5)
12 | self.add_data_point("Mon", 10)
13 | self.add_data_point("Tue", 20)
14 | self.add_data_point("Wed", 40)
15 | self.add_data_point("Thu", 80)
16 | self.add_data_point("Fri", 65)
17 | self.add_data_point("Sat", 50)
18 | self.add_slide("Area Chart
" + self.extract_chart())
19 | self.begin_presentation(filename="line_chart.html", interval=4)
20 |
--------------------------------------------------------------------------------
/examples/chart_maker/test_line_chart.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyChartMakerClass(BaseCase):
6 | def test_line_chart(self):
7 | self.create_presentation()
8 | self.create_line_chart(
9 | title="Time Outside", subtitle="Last Week", unit="Minutes"
10 | )
11 | self.add_data_point("Sun", 5)
12 | self.add_data_point("Mon", 10)
13 | self.add_data_point("Tue", 20)
14 | self.add_data_point("Wed", 40)
15 | self.add_data_point("Thu", 80)
16 | self.add_data_point("Fri", 65)
17 | self.add_data_point("Sat", 50)
18 | self.add_slide("Line Chart
" + self.extract_chart())
19 | self.begin_presentation(filename="line_chart.html", interval=4)
20 |
--------------------------------------------------------------------------------
/examples/desktop_apps/ReadMe.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Desktop Apps
4 |
5 | * **Recorder** (Run using ``python recorder.py`` or ``sbase recorder``)
6 |
--------------------------------------------------------------------------------
/examples/desktop_apps/recorder.py:
--------------------------------------------------------------------------------
1 | """ Run this file using ``python recorder.py`` """
2 |
3 | import os
4 |
5 |
6 | def open_recorder_desktop_app():
7 | command = "sbase recorder"
8 | os.system(command)
9 |
10 |
11 | if __name__ == "__main__":
12 | open_recorder_desktop_app()
13 |
--------------------------------------------------------------------------------
/examples/example_config.cfg:
--------------------------------------------------------------------------------
1 | [nosetests]
2 | nocapture=1
3 | logging-level=INFO
4 | browser=chrome
5 |
--------------------------------------------------------------------------------
/examples/example_logs/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/example_logs/screenshot.png
--------------------------------------------------------------------------------
/examples/github_test.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class GitHubTests(BaseCase):
6 | def test_github(self):
7 | if self.headless or self.page_load_strategy == "none":
8 | self.open_if_not_url("about:blank")
9 | print("\n Unsupported mode for this test.")
10 | self.skip("Unsupported mode for this test.")
11 | self.open("https://github.com/seleniumbase/SeleniumBase")
12 | self.click_if_visible('[data-action="click:signup-prompt#dismiss"]')
13 | self.highlight("div.Layout-main")
14 | self.highlight("div.Layout-sidebar")
15 | self.assert_element("div.repository-content")
16 | self.assert_text("SeleniumBase", "strong a")
17 | self.js_click('a[title="seleniumbase"]')
18 | self.slow_click('td[class*="large"] a[title="fixtures"]')
19 | self.highlight('td[class*="large"] a[title="base_case.py"]', loops=8)
20 |
--------------------------------------------------------------------------------
/examples/handle_alert_test.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class HandleAlertTests(BaseCase):
6 | def test_alerts(self):
7 | self.open("about:blank")
8 | self.execute_script('window.alert("ALERT!!!");')
9 | self.sleep(1) # Not needed (Lets you see the alert pop up)
10 | self.assert_true(self.is_alert_present())
11 | self.accept_alert()
12 | self.sleep(1) # Not needed (Lets you see the alert go away)
13 | self.execute_script('window.prompt("My Prompt","defaultText");')
14 | self.sleep(1) # Not needed (Lets you see the alert pop up)
15 | alert = self.switch_to_alert()
16 | self.assert_equal(alert.text, "My Prompt") # Not input field
17 | self.dismiss_alert()
18 | self.sleep(1) # Not needed (Lets you see the alert go away)
19 | self.assert_false(self.is_alert_present())
20 | if self.browser == "safari" and self._reuse_session:
21 | # Alerts can freeze Safari if reusing the browser session
22 | self.driver.quit()
23 |
--------------------------------------------------------------------------------
/examples/locale_code_test.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class LocaleCodeTests(BaseCase):
6 | def test_locale_code(self):
7 | self.open("about:blank")
8 | locale_code = self.get_locale_code() # navigator.language
9 | print("\nYour Browser's Locale Code: %s" % locale_code)
10 | if self.browser == "chrome" and not self.headless:
11 | self.open("chrome://settings/languages")
12 | language_info = self.get_text(
13 | "settings-ui::shadow "
14 | "settings-main::shadow "
15 | "settings-basic-page::shadow "
16 | "settings-languages-page::shadow "
17 | "#languagesSection div.start div"
18 | )
19 | print("Language info (chrome://settings/languages):")
20 | print(language_info)
21 | self.sleep(1)
22 |
--------------------------------------------------------------------------------
/examples/master_qa/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/master_qa/__init__.py
--------------------------------------------------------------------------------
/examples/master_qa/basic_masterqa_test_0.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import MasterQA
2 | MasterQA.main(__name__, __file__)
3 |
4 |
5 | class MasterQATests(MasterQA):
6 | def test_masterqa(self):
7 | self.open("https://seleniumbase.io/devices/")
8 | self.highlight("div.mockup-wrapper")
9 | self.verify("Do you see 4 computer devices?")
10 | self.open("https://seleniumbase.io/demo_page")
11 | self.highlight("table")
12 | self.verify("Do you see elements in a table?")
13 | self.open("https://xkcd.com/1700/")
14 | self.highlight("#comic")
15 | self.verify("Do you see a webcomic?")
16 |
--------------------------------------------------------------------------------
/examples/master_qa/masterqa_test_1.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import MasterQA
2 | MasterQA.main(__name__, __file__)
3 |
4 |
5 | class MasterQATests(MasterQA):
6 | def test_xkcd(self):
7 | self.open("https://xkcd.com/1512/")
8 | for i in range(4):
9 | self.click('a[rel="next"]')
10 | for i in range(3):
11 | self.click('a[rel="prev"]')
12 | self.verify()
13 | self.open("https://xkcd.com/1520/")
14 | for i in range(2):
15 | self.click('a[rel="next"]')
16 | self.verify("Can you find the moon?")
17 | self.click('a[rel="next"]')
18 | self.verify("Do the drones look safe?")
19 |
20 | self.open("https://seleniumbase.io/devices/")
21 | self.type("input#urlInput", "seleniumbase.io/error_page\n")
22 | self.verify("Do you see Octocat in a Jedi knight robe?")
23 |
24 | self.open("https://xkcd.com/213/")
25 | for i in range(5):
26 | self.click('a[rel="prev"]')
27 | self.verify("Does the page say 'Abnormal Expressions'?")
28 |
--------------------------------------------------------------------------------
/examples/migration/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/migration/__init__.py
--------------------------------------------------------------------------------
/examples/migration/protractor/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/migration/protractor/__init__.py
--------------------------------------------------------------------------------
/examples/migration/protractor/example_spec.js:
--------------------------------------------------------------------------------
1 | describe('angularjs homepage', function() {
2 | it('should greet the named user', function() {
3 | browser.get('http://www.angularjs.org');
4 |
5 | element(by.model('yourName')).sendKeys('Julie');
6 |
7 | var greeting = element(by.binding('yourName'));
8 |
9 | expect(greeting.getText()).toEqual('Hello Julie!');
10 | });
11 |
12 | describe('todo list', function() {
13 | var todoList;
14 |
15 | beforeEach(function() {
16 | browser.get('http://www.angularjs.org');
17 |
18 | todoList = element.all(by.repeater('todo in todoList.todos'));
19 | });
20 |
21 | it('should list todos', function() {
22 | expect(todoList.count()).toEqual(2);
23 | expect(todoList.get(1).getText()).toEqual('build an AngularJS app');
24 | });
25 |
26 | it('should add a todo', function() {
27 | var addTodo = element(by.model('todoList.todoText'));
28 | var addButton = element(by.css('[value="add"]'));
29 |
30 | addTodo.sendKeys('write a protractor test');
31 | addButton.click();
32 |
33 | expect(todoList.count()).toEqual(3);
34 | expect(todoList.get(2).getText()).toEqual('write a protractor test');
35 | });
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/examples/migration/protractor/example_test.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class AngularJSHomePageTests(BaseCase):
6 | def test_greet_user(self):
7 | self.open("http://www.angularjs.org")
8 | self.type('[ng-model="yourName"]', "Julie")
9 | self.assert_exact_text("Hello Julie!", "h1.ng-binding")
10 |
11 | def test_todo_list(self):
12 | self.open("http://www.angularjs.org")
13 | todo_selector = '[ng-repeat="todo in todoList.todos"]'
14 | # Verify that the todos are listed
15 | self.wait_for_element(todo_selector)
16 | todos = self.find_visible_elements(todo_selector)
17 | self.assert_equal(len(todos), 2)
18 | self.assert_equal(todos[1].text.strip(), "build an AngularJS app")
19 | # Verify adding a new todo
20 | self.type('[ng-model="todoList.todoText"]', "write a protractor test")
21 | self.click('[value="add"]')
22 | todos = self.find_visible_elements(todo_selector)
23 | self.assert_equal(len(todos), 3)
24 | self.assert_equal(todos[2].text.strip(), "write a protractor test")
25 |
--------------------------------------------------------------------------------
/examples/migration/protractor/input_spec.js:
--------------------------------------------------------------------------------
1 | describe('angular-material input component page', function() {
2 | const EC = protractor.ExpectedConditions;
3 |
4 | it('Should change input component value', async() => {
5 | await browser.get('https://material.angular.io/components/input/examples');
6 |
7 | await browser.wait(EC.elementToBeClickable($('.mat-button-wrapper > .mat-icon')), 5000);
8 |
9 | const emailInputField = $$('#mat-input-1').get(1);
10 |
11 | await emailInputField.sendKeys('invalid');
12 |
13 | expect($('mat-error').isPresent()).toBe(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/examples/migration/protractor/input_test.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class AngularMaterialInputTests(BaseCase):
6 | def test_invalid_input(self):
7 | # Test that there's an error for an invalid input
8 | self.open("https://material.angular.io/components/input/examples")
9 | self.type('input[type="email"]', "invalid")
10 | self.assert_element("mat-error")
11 |
--------------------------------------------------------------------------------
/examples/migration/protractor/mat_paginator_spec.js:
--------------------------------------------------------------------------------
1 | describe('angular-material paginator component page', () => {
2 | const EC = protractor.ExpectedConditions;
3 |
4 | beforeAll(async() => {
5 | await browser.get('https://material.angular.io/components/paginator/examples');
6 |
7 | await browser.wait(EC.elementToBeClickable($('.mat-button-wrapper > .mat-icon')), 5000);
8 | });
9 |
10 | it('Should navigate to next page', async() => {
11 | await $('button[aria-label=\'Next page\']').click();
12 |
13 | await expect($('.mat-paginator-range-label').getAttribute('innerText')).toEqual('Page 2 of 10');
14 | });
15 |
16 | it('Should navigate to previous page', async() => {
17 | await $('button[aria-label=\'Previous page\']').click();
18 |
19 | await expect($('.mat-paginator-range-label').getAttribute('innerText')).toEqual('Page 1 of 10');
20 | });
21 |
22 | it('Should change list length to 5 items per page', async() => {
23 | await $('mat-select > div').click();
24 |
25 | const fiveItemsOption = $$('mat-option > .mat-option-text').first();
26 |
27 | await fiveItemsOption.click();
28 |
29 | await expect($('.mat-paginator-range-label').getAttribute('innerText')).toEqual('Page 1 of 20');
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/examples/migration/raw_selenium/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/migration/raw_selenium/__init__.py
--------------------------------------------------------------------------------
/examples/migration/raw_selenium/simple_sbase.py:
--------------------------------------------------------------------------------
1 | """Clean SeleniumBase Example - (Uses simple, reliable methods)"""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class CleanSeleniumBase(BaseCase):
7 | def test_add_item_to_cart(self):
8 | self.open("https://www.saucedemo.com")
9 | self.type("#user-name", "standard_user")
10 | self.type("#password", "secret_sauce\n")
11 | self.assert_element("div.inventory_list")
12 | self.assert_text("Products", "span.title")
13 | self.click('button[name*="backpack"]')
14 | self.click("#shopping_cart_container a")
15 | self.assert_exact_text("Your Cart", "span.title")
16 | self.assert_text("Backpack", "div.cart_item")
17 | self.click("#remove-sauce-labs-backpack")
18 | self.assert_element_not_visible("div.cart_item")
19 | self.click("#react-burger-menu-btn")
20 | self.click("a#logout_sidebar_link")
21 | self.assert_element("input#login-button")
22 |
--------------------------------------------------------------------------------
/examples/multiple_cdp_drivers.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__, "--uc")
3 |
4 |
5 | class MultipleDriversTest(BaseCase):
6 | def test_multiple_drivers(self):
7 | url1 = "https://seleniumbase.io/demo_page"
8 | self.activate_cdp_mode(url1)
9 | driver1 = self.driver
10 | url2 = "https://seleniumbase.io/coffee/"
11 | driver2 = self.get_new_driver(undetectable=True)
12 | self.activate_cdp_mode(url2)
13 | print("\n" + driver1.get_current_url())
14 | print(driver2.get_current_url())
15 |
--------------------------------------------------------------------------------
/examples/offline_examples/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/offline_examples/__init__.py
--------------------------------------------------------------------------------
/examples/offline_examples/load_html_test.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | @pytest.mark.offline # Can be run with: "pytest -m offline"
7 | class OfflineTests(BaseCase):
8 | def test_load_html_string(self):
9 | html = "Hello OK!
"
10 | self.load_html_string(html) # Open "data:text/html," then replace html
11 | self.assert_text("Hello", "h2")
12 | self.assert_text("OK!", "button")
13 | self.type("input", "Goodbye")
14 | self.click("button")
15 | new_html = 'Checkbox Check Me!
'
16 | self.set_content(new_html) # Same as load_html_string(), but keeps URL
17 | self.assert_text("Checkbox", "h3")
18 | self.assert_text("Check Me!", "p")
19 | self.assert_false(self.is_selected("input"))
20 | self.click("input")
21 | self.assert_true(self.is_selected("input"))
22 |
--------------------------------------------------------------------------------
/examples/offline_examples/test_handle_alerts.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | @pytest.mark.offline # Can be run with: "pytest -m offline"
7 | class OfflineTests(BaseCase):
8 | def test_alerts(self):
9 | self.open("data:,")
10 | self.execute_script('window.alert("ALERT!!!");')
11 | self.sleep(1) # Not needed (Lets you see the alert pop up)
12 | self.accept_alert()
13 | self.sleep(1) # Not needed (Lets you see the alert go away)
14 | self.execute_script('window.prompt("My Prompt","defaultText");')
15 | self.sleep(1) # Not needed (Lets you see the alert pop up)
16 | alert = self.switch_to_alert()
17 | self.assert_equal(alert.text, "My Prompt") # Not input field
18 | self.dismiss_alert()
19 | self.sleep(1) # Not needed (Lets you see the alert go away)
20 | if self.browser == "safari" and self._reuse_session:
21 | # Alerts can freeze Safari if reusing the browser session
22 | self.driver.quit()
23 |
--------------------------------------------------------------------------------
/examples/offline_examples/test_request_fixture.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 |
4 | # Use the pytest "request" fixture to get the "sb" fixture (no class)
5 | @pytest.mark.offline
6 | def test_request_fixture(request):
7 | sb = request.getfixturevalue("sb")
8 | sb.open("data:text/html,Hello
")
9 | sb.assert_element("html > body")
10 | sb.assert_text("Hello", "body p")
11 | sb.type("input", "Goodbye")
12 | sb.click("body p")
13 | sb.tearDown()
14 |
15 |
16 | # Use the pytest "request" fixture to get the "sb" fixture (in class)
17 | @pytest.mark.offline
18 | class RequestTests:
19 | def test_request_fixture_in_class(self, request):
20 | sb = request.getfixturevalue("sb")
21 | sb.open("data:text/html,Hello
")
22 | sb.assert_element("html > body")
23 | sb.assert_text("Hello", "body p")
24 | sb.type("input", "Goodbye")
25 | sb.click("body p")
26 | sb.tearDown()
27 |
--------------------------------------------------------------------------------
/examples/parameterized_test.py:
--------------------------------------------------------------------------------
1 | from parameterized import parameterized
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class SearchTests(BaseCase):
7 | @parameterized.expand(
8 | [
9 | ["SeleniumBase Commander", "Commander", "GUI / Commander"],
10 | ["SeleniumBase Recorder", "Recorder", "Recorder Mode"],
11 | ["SeleniumBase Syntax", "Syntax", "Syntax Formats"],
12 | ]
13 | )
14 | def test_parameterized_search(self, search_term, keyword, title_text):
15 | self.open("https://seleniumbase.io/help_docs/how_it_works/")
16 | self.assert_title_contains("SeleniumBase Docs")
17 | self.type('input[aria-label="Search"]', search_term)
18 | self.click('mark:contains("%s")' % keyword)
19 | self.assert_title_contains(title_text)
20 |
--------------------------------------------------------------------------------
/examples/presenter/multi_uc.py:
--------------------------------------------------------------------------------
1 | """Part of the UC presentation"""
2 | import pytest
3 | from random import randint
4 | from seleniumbase import BaseCase
5 | BaseCase.main(__name__, __file__, "--uc", "-n3")
6 |
7 |
8 | @pytest.mark.parametrize("", [[]] * 3)
9 | def test_multi_threaded(sb):
10 | url = "https://gitlab.com/users/sign_in"
11 | sb.driver.uc_open_with_reconnect(url, 3)
12 | sb.set_window_rect(randint(0, 755), randint(38, 403), 700, 500)
13 | try:
14 | sb.assert_text("Username", '[for="user_login"]', timeout=3)
15 | sb.post_message("SeleniumBase wasn't detected", duration=4)
16 | sb._print("\n Success! Website did not detect Selenium! ")
17 | except Exception:
18 | sb.driver.uc_open_with_reconnect(url, 3)
19 | try:
20 | sb.assert_text("Username", '[for="user_login"]', timeout=3)
21 | sb.post_message("SeleniumBase wasn't detected", duration=4)
22 | sb._print("\n Success! Website did not detect Selenium! ")
23 | except Exception:
24 | sb.fail('Selenium was detected! Try using: "pytest --uc"')
25 |
--------------------------------------------------------------------------------
/examples/rate_limiting_test.py:
--------------------------------------------------------------------------------
1 | """This test demonstrates the use of the "rate_limited" decorator.
2 | You can use this decorator on any method to rate-limit it."""
3 | from seleniumbase import BaseCase
4 | from seleniumbase import decorators
5 |
6 |
7 | class RateLimitingTests(BaseCase):
8 | @decorators.rate_limited(4.2) # The arg is max calls per second
9 | def print_item(self, item):
10 | print(item)
11 |
12 | def test_rate_limited_printing(self):
13 | if self._multithreaded or self.recorder_mode:
14 | self.open_if_not_url("about:blank")
15 | print("\n Unsupported mode for this test.")
16 | self.skip("Unsupported mode for this test.")
17 | message = "Running rate-limited print() on the command line"
18 | self.open("data:text/html,%s
" % message)
19 | print("\n%s:" % message)
20 | for item in range(1, 11):
21 | self.print_item(item)
22 |
--------------------------------------------------------------------------------
/examples/raw_ahrefs.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, incognito=True, locale="en") as sb:
4 | url = "https://ahrefs.com/website-authority-checker"
5 | input_field = 'input[placeholder="Enter domain"]'
6 | submit_button = 'span:contains("Check Authority")'
7 | sb.uc_open_with_reconnect(url) # The bot-check is later
8 | sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
9 | sb.uc_click(submit_button, reconnect_time=3.25)
10 | sb.uc_gui_click_captcha()
11 | sb.wait_for_text_not_visible("Checking", timeout=15)
12 | sb.click_if_visible('button[data-cky-tag="close-button"]')
13 | sb.highlight('p:contains("github.com/seleniumbase/SeleniumBase")')
14 | sb.highlight('a:contains("Top 100 backlinks")')
15 | sb.set_messenger_theme(location="bottom_center")
16 | sb.post_message("SeleniumBase wasn't detected!")
17 |
--------------------------------------------------------------------------------
/examples/raw_antibot_login.py:
--------------------------------------------------------------------------------
1 | """UC Mode has PyAutoGUI methods for CAPTCHA-bypass."""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True) as sb:
5 | url = "https://seleniumbase.io/antibot/login"
6 | sb.uc_open_with_disconnect(url, 2.15)
7 | sb.uc_gui_write("\t" + "demo_user")
8 | sb.uc_gui_write("\t" + "secret_pass")
9 | sb.uc_gui_press_keys("\t" + " ") # For Single-char keys
10 | sb.sleep(1.5)
11 | sb.uc_gui_press_keys(["\t", "ENTER"]) # Multi-char keys
12 | sb.reconnect(1.8)
13 | sb.assert_text("Welcome!", "h1")
14 | sb.set_messenger_theme(location="bottom_center")
15 | sb.post_message("SeleniumBase wasn't detected!")
16 |
--------------------------------------------------------------------------------
/examples/raw_bing_captcha.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | url = "https://www.bing.com/turing/captcha/challenge"
5 | sb.uc_open_with_reconnect(url, 4)
6 | sb.uc_gui_click_captcha()
7 |
--------------------------------------------------------------------------------
/examples/raw_block.py:
--------------------------------------------------------------------------------
1 | """If Brotector catches you, Gandalf blocks you!"""
2 | from seleniumbase import SB
3 |
4 | with SB(test=True) as sb:
5 | url = "https://seleniumbase.io/hobbit/login"
6 | sb.open(url)
7 | sb.click_if_visible("button")
8 | sb.assert_text("Gandalf blocked you!", "h1")
9 | sb.click("img")
10 | sb.highlight("h1")
11 | sb.sleep(3) # Gandalf: "You Shall Not Pass!"
12 |
--------------------------------------------------------------------------------
/examples/raw_brotector_captcha.py:
--------------------------------------------------------------------------------
1 | """UC Mode has PyAutoGUI methods for CAPTCHA-bypass."""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True) as sb:
5 | url = "https://seleniumbase.io/apps/brotector"
6 | sb.uc_open_with_disconnect(url, 2.2)
7 | sb.uc_gui_press_key("\t")
8 | sb.uc_gui_press_key(" ")
9 | sb.reconnect(2.2)
10 |
--------------------------------------------------------------------------------
/examples/raw_call.py:
--------------------------------------------------------------------------------
1 | """Can run with "python" instead of using "pytest" directly.
2 | Usage: "python raw_call.py".
3 | Two examples: pytest.main() and subprocess.call()."""
4 | import pytest
5 | import subprocess
6 |
7 | if __name__ == "__main__":
8 | pytest.main(["test_coffee_cart.py", "--chrome", "-v"])
9 | subprocess.call(["pytest", "test_mfa_login.py", "--chrome", "-v"])
10 |
--------------------------------------------------------------------------------
/examples/raw_cdp_drivers.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | url1 = "https://seleniumbase.io/demo_page"
5 | sb.activate_cdp_mode(url1)
6 | driver1 = sb.driver
7 | url2 = "https://seleniumbase.io/coffee/"
8 | driver2 = sb.get_new_driver(undetectable=True)
9 | sb.activate_cdp_mode(url2)
10 | print(driver1.get_current_url())
11 | print(driver2.get_current_url())
12 | sb.switch_to_default_driver()
13 | sb.assert_url_contains("demo_page")
14 | print(sb.get_current_url())
15 | sb.switch_to_driver(driver2)
16 | sb.assert_url_contains("coffee")
17 | print(sb.get_current_url())
18 |
--------------------------------------------------------------------------------
/examples/raw_cdp_logging.py:
--------------------------------------------------------------------------------
1 | from rich.pretty import pprint
2 | from seleniumbase import Driver
3 |
4 | driver = Driver(uc=True, log_cdp=True)
5 | try:
6 | url = "seleniumbase.io/apps/turnstile"
7 | driver.uc_open_with_reconnect(url, 2)
8 | driver.uc_gui_handle_captcha()
9 | driver.sleep(2)
10 | pprint(driver.get_log("performance"))
11 | finally:
12 | driver.quit()
13 |
--------------------------------------------------------------------------------
/examples/raw_cf.py:
--------------------------------------------------------------------------------
1 | """SB Manager using UC Mode & PyAutoGUI for bypassing CAPTCHAs."""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True, locale="en") as sb:
5 | url = "https://www.cloudflare.com/login"
6 | sb.uc_open_with_reconnect(url, 5.5)
7 | sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar
8 | sb.sleep(2.5)
9 |
10 | with SB(uc=True, test=True, locale="en") as sb:
11 | url = "https://www.cloudflare.com/login"
12 | sb.uc_open_with_reconnect(url, 5.5)
13 | sb.uc_gui_click_captcha() # PyAutoGUI click. (Linux needs it)
14 | sb.sleep(2.5)
15 |
--------------------------------------------------------------------------------
/examples/raw_cookies.py:
--------------------------------------------------------------------------------
1 | """A SeleniumBase test that loads cookies to bypass login."""
2 | from seleniumbase import SB
3 |
4 | # Log in to Swag Labs and save cookies
5 | with SB(test=True) as sb:
6 | sb.open("https://www.saucedemo.com")
7 | sb.wait_for_element("div.login_logo")
8 | sb.type("#user-name", "standard_user")
9 | sb.type("#password", "secret_sauce")
10 | sb.click('input[type="submit"]')
11 | sb.highlight("div.inventory_list", loops=6)
12 | sb.save_cookies(name="cookies.txt")
13 |
14 | # Load previously saved cookies to bypass login
15 | with SB(test=True) as sb:
16 | sb.open("https://www.saucedemo.com")
17 | sb.load_cookies(name="cookies.txt")
18 | sb.open("https://www.saucedemo.com/inventory.html")
19 | sb.highlight("div.inventory_list", loops=12)
20 |
--------------------------------------------------------------------------------
/examples/raw_detection.py:
--------------------------------------------------------------------------------
1 | """The Brotector CAPTCHA in action."""
2 | from seleniumbase import SB
3 |
4 | with SB(test=True) as sb:
5 | sb.open("https://seleniumbase.io/antibot/login")
6 | sb.highlight("h4", loops=6)
7 | sb.type("#username", "demo_user")
8 | sb.type("#password", "secret_pass")
9 | sb.click_if_visible("button span")
10 | sb.highlight("label#pText")
11 | sb.highlight("table#detections")
12 | sb.sleep(4.4) # Add time to read the table
13 |
--------------------------------------------------------------------------------
/examples/raw_driver_context.py:
--------------------------------------------------------------------------------
1 | """DriverContext() example. (Runs with "python")."""
2 | from seleniumbase import DriverContext
3 |
4 | with DriverContext() as driver:
5 | driver.open("seleniumbase.io/")
6 | driver.highlight('img[alt="SeleniumBase"]', loops=6)
7 |
8 | with DriverContext(browser="chrome", incognito=True) as driver:
9 | driver.open("seleniumbase.io/apps/calculator")
10 | driver.click('[id="4"]')
11 | driver.click('[id="2"]')
12 | driver.assert_text("42", "#output")
13 | driver.highlight("#output", loops=6)
14 |
15 | with DriverContext() as driver:
16 | driver.open("seleniumbase.io/demo_page")
17 | driver.highlight("h2")
18 | driver.type("#myTextInput", "Automation")
19 | driver.click("#checkBox1")
20 | driver.highlight("img", loops=6)
21 |
--------------------------------------------------------------------------------
/examples/raw_driver_manager.py:
--------------------------------------------------------------------------------
1 | """Driver() manager example. (Runs with "python")."""
2 | from seleniumbase import Driver
3 |
4 | driver = Driver()
5 | try:
6 | driver.open("seleniumbase.io/demo_page")
7 | driver.highlight("h2")
8 | driver.type("#myTextInput", "Automation")
9 | driver.click("#checkBox1")
10 | driver.highlight("img", loops=6)
11 | finally:
12 | driver.quit()
13 |
14 | driver = Driver(browser="chrome", headless=False)
15 | try:
16 | driver.open("seleniumbase.io/apps/calculator")
17 | driver.click('[id="4"]')
18 | driver.click('[id="2"]')
19 | driver.assert_text("42", "#output")
20 | driver.highlight("#output", loops=6)
21 | finally:
22 | driver.quit()
23 |
--------------------------------------------------------------------------------
/examples/raw_file_call.py:
--------------------------------------------------------------------------------
1 | """Call a file with "python" instead of "pytest" directly.
2 | Added pytest args from the command-line won't be included.
3 | To run, use: "python raw_file_call.py"."""
4 | from seleniumbase import BaseCase
5 | if __name__ == "__main__":
6 | from pytest import main
7 | main([__file__, "-s"])
8 |
9 |
10 | class TinyMceTest(BaseCase):
11 | def test_tinymce(self):
12 | self.open("https://seleniumbase.io/tinymce/")
13 | self.wait_for_element("div.mce-container-body")
14 | self.click('span:contains("File")')
15 | self.click('span:contains("New document")')
16 | self.click('span:contains("Paragraph")')
17 | self.click('span:contains("Heading 1")')
18 | with self.frame_switch("iframe"):
19 | self.add_text("#tinymce", "SeleniumBase!")
20 | self.highlight("#tinymce")
21 | self.post_message("SeleniumBase is fast!", duration=1.5)
22 | self.post_message("And SeleniumBase is fun!", duration=1.5)
23 |
--------------------------------------------------------------------------------
/examples/raw_form_turnstile.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | url = "seleniumbase.io/apps/form_turnstile"
5 | sb.uc_open_with_reconnect(url, 2)
6 | sb.press_keys("#name", "SeleniumBase")
7 | sb.press_keys("#email", "test@test.test")
8 | sb.press_keys("#phone", "1-555-555-5555")
9 | sb.click('[for="date"]')
10 | sb.click("td.is-today button")
11 | sb.click('div[class="select-wrapper"] input')
12 | sb.click('span:contains("9:00 PM")')
13 | sb.highlight_click('input[value="AR"] + span')
14 | sb.click('input[value="cc"] + span')
15 | sb.scroll_to('div[class*="cf-turnstile"]')
16 | sb.uc_gui_handle_captcha()
17 | sb.highlight("img#captcha-success", timeout=3)
18 | sb.highlight_click('button:contains("Request & Pay")')
19 | sb.highlight("img#submit-success")
20 | sb.highlight('button:contains("Success!")')
21 |
--------------------------------------------------------------------------------
/examples/raw_games.py:
--------------------------------------------------------------------------------
1 | """SB Manager using UC Mode for evading bot-detection."""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True, disable_csp=True) as sb:
5 | url = "https://steamdb.info/"
6 | sb.uc_open_with_reconnect(url, 3)
7 | sb.uc_click("a.header-login span", 3)
8 | sb.uc_gui_click_captcha()
9 | sb.assert_text("Sign in", "button#js-sign-in", timeout=4)
10 | sb.uc_click("button#js-sign-in", 2)
11 | sb.highlight("div.page_content form")
12 | sb.highlight('button:contains("Sign in")', scroll=False)
13 | sb.set_messenger_theme(location="top_center")
14 | sb.post_message("SeleniumBase wasn't detected", duration=4)
15 |
--------------------------------------------------------------------------------
/examples/raw_google.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(test=True, uc=True) as sb:
4 | sb.open("https://google.com/ncr")
5 | sb.type('[title="Search"]', "SeleniumBase GitHub page\n")
6 | sb.click('[href*="github.com/seleniumbase/"]')
7 | sb.save_screenshot_to_logs() # ./latest_logs/
8 | print(sb.get_page_title())
9 |
--------------------------------------------------------------------------------
/examples/raw_gui_click.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from seleniumbase import SB
3 |
4 | # An bad UserAgent forces CAPTCHA-solving on macOS
5 | agent = "cool"
6 | if "linux" in sys.platform or "win32" in sys.platform:
7 | agent = None # Use the default UserAgent
8 |
9 | with SB(uc=True, test=True, rtf=True, agent=agent) as sb:
10 | url = "https://gitlab.com/users/sign_in"
11 | sb.uc_open_with_reconnect(url)
12 | sb.uc_gui_click_captcha() # Only if needed
13 | sb.assert_element('label[for="user_login"]')
14 | sb.assert_element('input[data-testid*="username"]')
15 | sb.assert_element('input[data-testid*="password"]')
16 | sb.set_messenger_theme(location="bottom_center")
17 | sb.post_message("SeleniumBase wasn't detected!")
18 |
--------------------------------------------------------------------------------
/examples/raw_hobbit.py:
--------------------------------------------------------------------------------
1 | """UC Mode has PyAutoGUI methods for CAPTCHA-bypass."""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True) as sb:
5 | url = "https://seleniumbase.io/hobbit/login"
6 | sb.uc_open_with_disconnect(url, 2.2)
7 | sb.uc_gui_press_keys("\t ")
8 | sb.reconnect(1.5)
9 | sb.assert_text("Welcome to Middle Earth!", "h1")
10 | sb.set_messenger_theme(location="bottom_center")
11 | sb.post_message("SeleniumBase wasn't detected!")
12 | sb.click("img")
13 | sb.sleep(5.888) # Cool animation happening now!
14 |
--------------------------------------------------------------------------------
/examples/raw_invisible_captcha.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, incognito=True) as sb:
4 | url = "https://seleniumbase.io/apps/invisible_recaptcha"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(1)
7 | sb.assert_element("img#captcha-success", timeout=3)
8 | sb.set_messenger_theme(location="top_left")
9 | sb.post_message("SeleniumBase wasn't detected", duration=3)
10 |
--------------------------------------------------------------------------------
/examples/raw_login_context.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import DriverContext
2 |
3 | with DriverContext() as driver:
4 | driver.open("seleniumbase.io/simple/login")
5 | driver.type("#username", "demo_user")
6 | driver.type("#password", "secret_pass")
7 | driver.click('a:contains("Sign in")')
8 | driver.assert_exact_text("Welcome!", "h1")
9 | driver.assert_element("img#image1")
10 | driver.highlight("#image1")
11 | driver.click_link("Sign out")
12 | driver.assert_text("signed out", "#top_message")
13 |
--------------------------------------------------------------------------------
/examples/raw_login_driver.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import Driver
2 |
3 | driver = Driver()
4 | try:
5 | driver.open("seleniumbase.io/simple/login")
6 | driver.type("#username", "demo_user")
7 | driver.type("#password", "secret_pass")
8 | driver.click('a:contains("Sign in")')
9 | driver.assert_exact_text("Welcome!", "h1")
10 | driver.assert_element("img#image1")
11 | driver.highlight("#image1")
12 | driver.click_link("Sign out")
13 | driver.assert_text("signed out", "#top_message")
14 | finally:
15 | driver.quit()
16 |
--------------------------------------------------------------------------------
/examples/raw_login_sb.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB() as sb:
4 | sb.open("seleniumbase.io/simple/login")
5 | sb.type("#username", "demo_user")
6 | sb.type("#password", "secret_pass")
7 | sb.click('a:contains("Sign in")')
8 | sb.assert_exact_text("Welcome!", "h1")
9 | sb.assert_element("img#image1")
10 | sb.highlight("#image1")
11 | sb.click_link("Sign out")
12 | sb.assert_text("signed out", "#top_message")
13 |
--------------------------------------------------------------------------------
/examples/raw_main_call.py:
--------------------------------------------------------------------------------
1 | """Can use "python" instead of using "pytest".
2 | Added pytest args will be included in the run.
3 | Example usage: "python raw_file_call.py"."""
4 | from seleniumbase import BaseCase
5 | BaseCase.main(__name__, __file__)
6 |
7 |
8 | class TinyMceTest(BaseCase):
9 | def test_tinymce(self):
10 | self.open("https://seleniumbase.io/tinymce/")
11 | self.wait_for_element("div.mce-container-body")
12 | self.click('span:contains("File")')
13 | self.click('span:contains("New document")')
14 | self.click('span:contains("Paragraph")')
15 | self.click('span:contains("Heading 1")')
16 | with self.frame_switch("iframe"):
17 | self.add_text("#tinymce", "SeleniumBase!")
18 | self.highlight("#tinymce")
19 | self.post_message("SeleniumBase is fast!", duration=1.5)
20 | self.post_message("And SeleniumBase is fun!", duration=1.5)
21 |
--------------------------------------------------------------------------------
/examples/raw_mobile.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import Driver
2 |
3 | driver = Driver(mobile=True)
4 | try:
5 | driver.open("https://www.skype.com/en/get-skype/")
6 | driver.assert_element('[aria-label="Microsoft"]')
7 | driver.assert_text("Download Skype", "h1")
8 | driver.highlight("div.appBannerContent")
9 | driver.highlight("h1")
10 | driver.assert_text("Skype for Mobile", "h2")
11 | driver.highlight("h2")
12 | driver.highlight("#get-skype-0")
13 | driver.highlight_click("span[data-dropdown-icon]")
14 | driver.highlight("#get-skype-0_android-download")
15 | driver.highlight('[data-bi-id*="ios"]')
16 | finally:
17 | driver.quit()
18 |
--------------------------------------------------------------------------------
/examples/raw_multi_drivers.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import threading
3 | from concurrent.futures import ThreadPoolExecutor
4 | from random import randint, seed
5 | from seleniumbase import Driver
6 | sys.argv.append("-n") # Tell SeleniumBase to do thread-locking as needed
7 |
8 |
9 | def launch_driver(url):
10 | seed(len(threading.enumerate())) # Random seed for browser placement
11 | driver = Driver()
12 | try:
13 | driver.set_window_rect(randint(4, 720), randint(8, 410), 700, 500)
14 | driver.get(url=url)
15 | if driver.is_element_visible("h1"):
16 | driver.highlight("h1", loops=9)
17 | else:
18 | driver.sleep(2.2)
19 | finally:
20 | driver.quit()
21 |
22 |
23 | if __name__ == "__main__":
24 | urls = ['https://seleniumbase.io/demo_page' for i in range(4)]
25 | with ThreadPoolExecutor(max_workers=len(urls)) as executor:
26 | for url in urls:
27 | executor.submit(launch_driver, url)
28 |
--------------------------------------------------------------------------------
/examples/raw_nopecha.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | sb.uc_open_with_reconnect("nopecha.com/demo/turnstile", 3.2)
5 | if sb.is_element_visible("#example-container0"):
6 | sb.uc_gui_click_captcha("#example-container0")
7 | sb.uc_gui_click_captcha("#example-container5")
8 | sb.sleep(3)
9 |
--------------------------------------------------------------------------------
/examples/raw_order_tickets.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, ad_block=True) as sb:
4 | url = "https://www.thaiticketmajor.com/concert/#"
5 | sb.uc_open_with_reconnect(url, 6.111)
6 | sb.uc_click("button.btn-signin", 4.1)
7 | sb.uc_gui_click_captcha()
8 | sb.sleep(2)
9 |
--------------------------------------------------------------------------------
/examples/raw_performance_logs.py:
--------------------------------------------------------------------------------
1 | from rich.pretty import pprint
2 | from seleniumbase import SB
3 |
4 | with SB(log_cdp=True) as sb:
5 | sb.open("seleniumbase.io/demo_page")
6 | sb.sleep(1)
7 | pprint(sb.driver.get_log("performance"))
8 |
--------------------------------------------------------------------------------
/examples/raw_pixelscan.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, incognito=True, test=True) as sb:
4 | url = "https://pixelscan.net/fingerprint-check"
5 | sb.driver.uc_open_with_reconnect(url, 7)
6 | sb.remove_elements(".bg-bannerBg") # Remove top banner
7 | sb.remove_elements("pxlscn-ad1") # Remove an ad banner
8 | sb.remove_elements("pxlscn-ad2") # Remove an ad banner
9 | sb.remove_elements("jdiv") # Remove chat widgets
10 | not_masking_text = "You are not masking your fingerprint"
11 | fp_selector = "pxlscn-fingerprint-masking"
12 | sb.assert_text(not_masking_text, fp_selector, timeout=15)
13 | no_automation_detected = "No automation framework detected"
14 | sb.assert_text(no_automation_detected, "pxlscn-bot-detection")
15 | consistent_selector = 'div.bg-consistentBg [alt="Good"]'
16 | consistent_selector = 'div.bg-consistentBg [alt="Good"]'
17 | sb.highlight(consistent_selector, loops=8, scroll=False)
18 | sb.sleep(1)
19 | fingerprint_masking_div = "pxlscn-fingerprint-masking div"
20 | sb.highlight(fingerprint_masking_div, loops=9, scroll=False)
21 | sb.sleep(1)
22 | sb.highlight("pxlscn-bot-detection", loops=10, scroll=False)
23 | sb.sleep(2)
24 |
--------------------------------------------------------------------------------
/examples/raw_pyautogui.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from seleniumbase import SB
3 |
4 | # An bad UserAgent forces CAPTCHA-solving on macOS
5 | agent = "cool"
6 | if "linux" in sys.platform or "win32" in sys.platform:
7 | agent = None # Use the default UserAgent
8 |
9 | with SB(uc=True, test=True, rtf=True, agent=agent) as sb:
10 | url = "https://gitlab.com/users/sign_in"
11 | sb.uc_open_with_reconnect(url)
12 | sb.uc_gui_handle_captcha() # Only if needed
13 | sb.assert_element('label[for="user_login"]')
14 | sb.assert_element('input[data-testid*="username"]')
15 | sb.assert_element('input[data-testid*="password"]')
16 | sb.set_messenger_theme(location="bottom_center")
17 | sb.post_message("SeleniumBase wasn't detected!")
18 |
--------------------------------------------------------------------------------
/examples/raw_recaptcha.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True, incognito=True) as sb:
4 | url = "https://seleniumbase.io/apps/recaptcha"
5 | sb.activate_cdp_mode(url)
6 | sb.sleep(1)
7 | sb.uc_gui_click_captcha('iframe[src*="/recaptcha/"]')
8 | sb.assert_element("img#captcha-success", timeout=3)
9 | sb.set_messenger_theme(location="top_left")
10 | sb.post_message("SeleniumBase wasn't detected", duration=3)
11 |
--------------------------------------------------------------------------------
/examples/raw_robot.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(enable_3d_apis=True, test=True) as sb:
4 | sb.open("threejs.org/examples/#webgl_animation_skinning_morph")
5 | sb.switch_to_frame("iframe#viewer")
6 | sb.set_text_content("#info p", "Hi, I'm Michael Mintz")
7 | sb.add_css_style("#info p{zoom: 2.54}")
8 | sb.sleep(0.8)
9 | sb.click('button:contains("Wave")')
10 | sb.highlight("#info p")
11 | sb.select_option_by_text("select", "Idle")
12 | sb.click('button:contains("ThumbsUp")')
13 | sb.set_text_content("#info p", "I created SeleniumBase")
14 | sb.highlight("#info p")
15 | sb.sleep(0.8)
16 | sb.click('button:contains("Jump")')
17 | sb.sleep(1.5)
18 |
--------------------------------------------------------------------------------
/examples/raw_sb.py:
--------------------------------------------------------------------------------
1 | """SB() context manager example. (Runs with "python")."""
2 | from seleniumbase import SB
3 |
4 | with SB() as sb: # By default, browser="chrome" if not set.
5 | sb.open("https://seleniumbase.io/realworld/login")
6 | sb.type("#username", "demo_user")
7 | sb.type("#password", "secret_pass")
8 | sb.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") # 6-digit
9 | sb.assert_text("Welcome!", "h1")
10 | sb.highlight("img#image1") # A fancier assert_element() call
11 | sb.click('a:contains("This Page")') # Use :contains() on any tag
12 | sb.click_link("Sign out") # Link must be "a" tag. Not "button".
13 | sb.assert_element('a:contains("Sign in")')
14 | sb.assert_exact_text("You have been signed out!", "#top_message")
15 |
--------------------------------------------------------------------------------
/examples/raw_skype_mobile.py:
--------------------------------------------------------------------------------
1 | """Mobile emulation test for Skype."""
2 | from seleniumbase import SB
3 |
4 | with SB(mobile=True, test=True) as sb:
5 | sb.open("https://www.skype.com/en/get-skype/")
6 | sb.assert_element('[aria-label="Microsoft"]')
7 | sb.assert_text("Download Skype", "h1")
8 | sb.highlight("div.appBannerContent")
9 | sb.highlight("h1")
10 | sb.assert_text("Skype for Mobile", "h2")
11 | sb.highlight("h2")
12 | sb.highlight("#get-skype-0")
13 | sb.highlight_click("span[data-dropdown-icon]")
14 | sb.highlight("#get-skype-0_android-download")
15 | sb.highlight('[data-bi-id*="ios"]')
16 |
--------------------------------------------------------------------------------
/examples/raw_test_scripts.py:
--------------------------------------------------------------------------------
1 | """Context Manager Test. Runs with "python". (pytest not needed)"""
2 | from seleniumbase import SB
3 |
4 | with SB(test=True, uc=True) as sb:
5 | sb.open("https://google.com/ncr")
6 | sb.type('[name="q"]', "SeleniumBase on GitHub\n")
7 | sb.click('a[href*="github.com/seleniumbase"]')
8 | sb.highlight("div.Layout-main")
9 | sb.highlight("div.Layout-sidebar")
10 | sb.sleep(0.5)
11 |
12 | with SB(test=True, rtf=True, demo=True) as sb:
13 | sb.open("seleniumbase.github.io/demo_page")
14 | sb.type("#myTextInput", "This is Automated")
15 | sb.assert_text("This is Automated", "#myTextInput")
16 | sb.assert_text("This Text is Green", "#pText")
17 | sb.click('button:contains("Click Me")')
18 | sb.assert_text("This Text is Purple", "#pText")
19 | sb.click("#checkBox1")
20 | sb.assert_element_not_visible("div#drop2 img#logo")
21 | sb.drag_and_drop("img#logo", "div#drop2")
22 | sb.assert_element("div#drop2 img#logo")
23 |
--------------------------------------------------------------------------------
/examples/raw_turnstile.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import SB
2 |
3 | with SB(uc=True, test=True) as sb:
4 | url = "https://seleniumbase.io/apps/turnstile"
5 | sb.uc_open_with_reconnect(url)
6 | sb.uc_gui_click_captcha()
7 | sb.assert_element("img#captcha-success", timeout=3)
8 | sb.set_messenger_theme(location="top_left")
9 | sb.post_message("SeleniumBase wasn't detected", duration=3)
10 |
--------------------------------------------------------------------------------
/examples/raw_uc_events.py:
--------------------------------------------------------------------------------
1 | from rich.pretty import pprint
2 | from seleniumbase import SB
3 |
4 |
5 | def add_cdp_listener(sb):
6 | # (To print everything, use "*". Otherwise select specific headers.)
7 | # self.driver.add_cdp_listener("*", lambda data: print(pformat(data)))
8 | sb.driver.add_cdp_listener(
9 | "Network.requestWillBeSentExtraInfo",
10 | lambda data: pprint(data)
11 | )
12 |
13 |
14 | def click_turnstile_and_verify(sb):
15 | sb.uc_gui_handle_captcha()
16 | sb.assert_element("img#captcha-success", timeout=3)
17 | sb.highlight("img#captcha-success", loops=8)
18 |
19 |
20 | with SB(uc_cdp_events=True, test=True) as sb:
21 | url = "seleniumbase.io/apps/turnstile"
22 | sb.uc_open_with_reconnect(url, 2)
23 | add_cdp_listener(sb)
24 | click_turnstile_and_verify(sb)
25 | sb.sleep(1)
26 | sb.refresh()
27 | sb.sleep(1.2)
28 |
--------------------------------------------------------------------------------
/examples/raw_uc_mode.py:
--------------------------------------------------------------------------------
1 | """SB Manager using UC Mode for evading bot-detection."""
2 | from seleniumbase import SB
3 |
4 | with SB(uc=True, test=True) as sb:
5 | url = "https://gitlab.com/users/sign_in"
6 | sb.uc_open_with_reconnect(url, 4)
7 | sb.uc_gui_click_captcha()
8 | sb.assert_text("Username", '[for="user_login"]', timeout=3)
9 | sb.assert_element('label[for="user_login"]')
10 | sb.highlight('button:contains("Sign in")')
11 | sb.highlight('h1:contains("GitLab.com")')
12 | sb.post_message("SeleniumBase wasn't detected", duration=4)
13 |
--------------------------------------------------------------------------------
/examples/sb_fixture_tests.py:
--------------------------------------------------------------------------------
1 | # "sb" pytest fixture test in a method with no class
2 | def test_sb_fixture_with_no_class(sb):
3 | sb.open("seleniumbase.io/simple/login")
4 | sb.type("#username", "demo_user")
5 | sb.type("#password", "secret_pass")
6 | sb.click('a:contains("Sign in")')
7 | sb.assert_exact_text("Welcome!", "h1")
8 | sb.assert_element("img#image1")
9 | sb.highlight("#image1")
10 | sb.click_link("Sign out")
11 | sb.assert_text("signed out", "#top_message")
12 |
13 |
14 | # "sb" pytest fixture test in a method inside a class
15 | class Test_SB_Fixture:
16 | def test_sb_fixture_inside_class(self, sb):
17 | sb.open("seleniumbase.io/simple/login")
18 | sb.type("#username", "demo_user")
19 | sb.type("#password", "secret_pass")
20 | sb.click('a:contains("Sign in")')
21 | sb.assert_exact_text("Welcome!", "h1")
22 | sb.assert_element("img#image1")
23 | sb.highlight("#image1")
24 | sb.click_link("Sign out")
25 | sb.assert_text("signed out", "#top_message")
26 |
--------------------------------------------------------------------------------
/examples/setup.cfg:
--------------------------------------------------------------------------------
1 | [flake8]
2 | # W503 (line break before binary operator) can be ignored.
3 | exclude=recordings,temp
4 | ignore=W503
5 |
6 | [nosetests]
7 | # nocapture=1 (Display print statements from output)
8 | # (Undo this by using: "--nologcapture")
9 | # logging-level=INFO (Shorter logs than using DEBUG)
10 | nocapture=1
11 | logging-level=INFO
12 |
13 | [behave]
14 | show_skipped=false
15 | show_timings=false
16 |
--------------------------------------------------------------------------------
/examples/shadow_root_test.py:
--------------------------------------------------------------------------------
1 | """Piercing through shadow-root elements with the "::shadow" selector.
2 | To confirm that "::shadow" works, print text and assert exact text."""
3 | from seleniumbase import BaseCase
4 | BaseCase.main(__name__, __file__)
5 |
6 |
7 | class ShadowRootTest(BaseCase):
8 | def test_shadow_root(self):
9 | if self.recorder_mode or not self.is_chromium():
10 | self.open_if_not_url("about:blank")
11 | print("\n Unsupported mode for this test.")
12 | self.skip("Unsupported mode for this test.")
13 | self.open("https://seleniumbase.io/other/shadow_dom")
14 | print("")
15 | self.click("button.tab_1")
16 | print(self.get_text("fancy-tabs::shadow #panels"))
17 | self.assert_exact_text("Content Panel 1", "fancy-tabs::shadow #panels")
18 | self.click("button.tab_2")
19 | print(self.get_text("fancy-tabs::shadow #panels"))
20 | self.assert_exact_text("Content Panel 2", "fancy-tabs::shadow #panels")
21 | self.click("button.tab_3")
22 | print(self.get_text("fancy-tabs::shadow #panels"))
23 | self.assert_exact_text("Content Panel 3", "fancy-tabs::shadow #panels")
24 |
--------------------------------------------------------------------------------
/examples/test_3d_apis.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__, "--enable-3d-apis")
3 |
4 |
5 | class ThreeJSTests(BaseCase):
6 | def test_animation(self):
7 | if self.headless:
8 | self.open_if_not_url("about:blank")
9 | self.skip("Skip this test in headless mode!")
10 | if self.is_chromium() and not self.enable_3d_apis:
11 | self.get_new_driver(enable_3d_apis=True) # --enable-3d-apis
12 | url = "https://threejs.org/examples/#webgl_animation_skinning_morph"
13 | self.open(url)
14 | self.switch_to_frame("iframe#viewer")
15 | self.sleep(0.8)
16 | self.click('button:contains("Wave")')
17 | self.sleep(3)
18 |
--------------------------------------------------------------------------------
/examples/test_assert_elements.py:
--------------------------------------------------------------------------------
1 | """Assert that multiple elements are present or visible:
2 | HTML Presence: assert_elements_present()
3 | HTML Visibility: assert_elements() <> assert_elements_visible()"""
4 | from seleniumbase import BaseCase
5 | BaseCase.main(__name__, __file__)
6 |
7 |
8 | class ListAssertTests(BaseCase):
9 | def test_assert_list_of_elements(self):
10 | self.open("https://seleniumbase.io/demo_page")
11 | self.assert_elements_present("head", "style", "script")
12 | self.assert_elements("h1", "h2", "h3")
13 | my_list = ["#myDropdown", "#myButton", "#mySlider"]
14 | self.assert_elements(my_list)
15 |
--------------------------------------------------------------------------------
/examples/test_calculator.py:
--------------------------------------------------------------------------------
1 | """Test the SeleniumBase Calculator App"""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class CalculatorTests(BaseCase):
7 | def test_6_times_7_plus_12_equals_54(self):
8 | self.open("seleniumbase.io/apps/calculator")
9 | self.click('button[id="6"]')
10 | self.click("button#multiply")
11 | self.click('button[id="7"]')
12 | self.click("button#add")
13 | self.click('button[id="1"]')
14 | self.click('button[id="2"]')
15 | self.click("button#equal")
16 | self.assert_exact_text("54", "input#output")
17 |
--------------------------------------------------------------------------------
/examples/test_checkboxes.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class CheckboxTests(BaseCase):
6 | def test_checkboxes_and_radio_buttons(self):
7 | self.open("https://seleniumbase.io/w3schools/checkboxes")
8 | self.click("button#runbtn")
9 | self.switch_to_frame("iframeResult")
10 | checkbox = "input#vehicle2"
11 | self.assert_false(self.is_selected(checkbox))
12 | self.click(checkbox)
13 | self.assert_true(self.is_selected(checkbox))
14 | self.open("https://seleniumbase.io/w3schools/radio_buttons")
15 | self.click("button#runbtn")
16 | self.switch_to_frame("iframeResult")
17 | option_button = "input#css"
18 | self.assert_false(self.is_selected(option_button))
19 | self.click(option_button)
20 | self.assert_true(self.is_selected(option_button))
21 |
--------------------------------------------------------------------------------
/examples/test_chinese_pdf.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class ChinesePdfTests(BaseCase):
6 | def test_chinese_pdf(self):
7 | self.open("data:,")
8 | pdf = "https://seleniumbase.io/cdn/pdf/unittest_zh.pdf"
9 |
10 | # Get and print PDF text
11 | pdf_text = self.get_pdf_text(pdf, page=2)
12 | print("\n" + pdf_text)
13 |
14 | # Assert PDF contains the expected text on Page 2
15 | self.assert_pdf_text(pdf, "个测试类", page=2)
16 |
17 | # Assert PDF contains the expected text on any of the pages
18 | self.assert_pdf_text(pdf, "运行单元测试")
19 | self.assert_pdf_text(pdf, "等待测试结束后显示所有结果")
20 | self.assert_pdf_text(pdf, "测试的执行跟方法的顺序没有关系")
21 |
--------------------------------------------------------------------------------
/examples/test_coffee_cart.py:
--------------------------------------------------------------------------------
1 | """Use SeleniumBase to test the Coffee Cart App."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class CoffeeCartTest(BaseCase):
7 | def test_coffee_cart(self):
8 | self.open("https://seleniumbase.io/coffee/")
9 | self.assert_title("Coffee Cart")
10 | self.assert_element('button:contains("Total: $0.00")')
11 | self.click('div[data-sb="Cappuccino"]')
12 | self.assert_exact_text("cart (1)", 'a[aria-label="Cart page"]')
13 | self.click('div[data-sb="Flat-White"]')
14 | self.assert_exact_text("cart (2)", 'a[aria-label="Cart page"]')
15 | self.click('div[data-sb="Cafe-Latte"]')
16 | self.assert_exact_text("cart (3)", 'a[aria-label="Cart page"]')
17 | self.click('a[aria-label="Cart page"]')
18 | self.assert_exact_text("Total: $53.00", "button.pay")
19 | self.click("button.pay")
20 | self.type("input#name", "Selenium Coffee")
21 | self.type("input#email", "test@test.test")
22 | self.click("button#submit-payment")
23 | self.assert_text("Thanks for your purchase.", "#app .success")
24 |
--------------------------------------------------------------------------------
/examples/test_console_logging.py:
--------------------------------------------------------------------------------
1 | """Use SeleniumBase methods to interact with console logs."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class TestConsoleLogging(BaseCase):
7 | def test_console_logging(self):
8 | self.open("https://seleniumbase.io/demo_page")
9 | self.wait_for_element_visible("h2")
10 | self.start_recording_console_logs()
11 | self.console_log_string("Hello World!")
12 | self.console_log_script('document.querySelector("h2").textContent')
13 | console_logs = [log[0] for log in self.get_recorded_console_logs()]
14 | self.assert_in("Hello World!", console_logs)
15 | self.assert_in("SeleniumBase", console_logs)
16 |
--------------------------------------------------------------------------------
/examples/test_contains_selector.py:
--------------------------------------------------------------------------------
1 | """TAG:contains("TEXT") is a special, non-standard CSS Selector
2 | that gets converted to XPath: '//TAG[contains(., "TEXT")]'
3 | before it's used by Selenium calls. Also part of jQuery."""
4 | from seleniumbase import BaseCase
5 | BaseCase.main(__name__, __file__)
6 |
7 |
8 | class ContainsSelectorTests(BaseCase):
9 | def test_contains_selector(self):
10 | self.open("https://xkcd.com/2207/")
11 | self.assert_element('div.box div:contains("Math Work")')
12 | self.click('a:contains("Next")')
13 | self.assert_element('div div:contains("Drone Fishing")')
14 |
--------------------------------------------------------------------------------
/examples/test_cycle_elements.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class CycleTests(BaseCase):
6 | def test_cycle_elements_with_tab_and_press_enter(self):
7 | """
8 | Test pressing the tab key to cycle through elements.
9 | Then click on the active element and verify actions.
10 | This can all be performed by using a single command.
11 | The "\t" is the tab key. The "\n" is the RETURN key.
12 | """
13 | self.open("seleniumbase.io/demo_page")
14 | self.assert_text("This Text is Green", "#pText")
15 | self.send_keys("html", "\t\t\t\t\n")
16 | self.assert_text("This Text is Purple", "#pText")
17 |
--------------------------------------------------------------------------------
/examples/test_decryption.py:
--------------------------------------------------------------------------------
1 | """This test demonstrates the use of password encryption/decryption.
2 | (Technically considered to be obfuscation/unobfuscation.)"""
3 | from seleniumbase import BaseCase
4 | from seleniumbase import encryption
5 | BaseCase.main(__name__, __file__)
6 |
7 |
8 | class DecryptionTests(BaseCase):
9 | def test_decrypt_password(self):
10 | self.open("https://www.saucedemo.com")
11 | self.type("#user-name", "standard_user")
12 |
13 | encrypted_password = "$^*ENCRYPT=S3BDTAdCWzMmKEY8Gjg=?$"
14 | print("\nEncrypted Password = %s" % encrypted_password)
15 | password = encryption.decrypt(encrypted_password)
16 | print("Decrypted Password = %s" % password)
17 | self.type("#password", password)
18 |
19 | self.click('input[type="submit"]')
20 | self.assert_element("#inventory_container")
21 | self.assert_element('div:contains("Sauce Labs Backpack")')
22 |
--------------------------------------------------------------------------------
/examples/test_deferred_asserts.py:
--------------------------------------------------------------------------------
1 | """This test shows the use of SeleniumBase deferred asserts.
2 | Deferred asserts won't raise exceptions from failures until
3 | process_deferred_asserts() is called, or the test completes."""
4 | import pytest
5 | from seleniumbase import BaseCase
6 | BaseCase.main(__name__, __file__)
7 |
8 |
9 | class DeferredAssertTests(BaseCase):
10 | @pytest.mark.expected_failure
11 | def test_deferred_asserts(self):
12 | self.open("https://xkcd.com/993/")
13 | self.wait_for_element("#comic")
14 | print("\n(This test should fail)")
15 | self.deferred_assert_element('img[alt="Brand Identity"]')
16 | self.deferred_assert_element('img[alt="Rocket Ship"]') # Will Fail
17 | self.deferred_assert_element("#comicmap")
18 | self.deferred_assert_text("Fake Item", "ul.comicNav") # Will Fail
19 | self.deferred_assert_text("Random", "ul.comicNav")
20 | self.deferred_assert_element('a[name="Super Fake !!!"]') # Will Fail
21 | self.deferred_assert_exact_text("Brand Identity", "#ctitle")
22 | self.deferred_assert_exact_text("Fake Food", "#comic") # Will Fail
23 | self.process_deferred_asserts()
24 |
--------------------------------------------------------------------------------
/examples/test_detect_404s.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class BrokenLinkTests(BaseCase):
6 | def test_link_checking(self):
7 | self.open("https://seleniumbase.io/other/broken_page.html")
8 | print("\n(This test should fail)")
9 | self.assert_no_404_errors()
10 |
--------------------------------------------------------------------------------
/examples/test_docs_site.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class DocsSiteTests(BaseCase):
6 | def test_docs(self):
7 | self.open("https://seleniumbase.io/help_docs/customizing_test_runs/")
8 | self.assert_text("Command Line Options", "h1")
9 | self.js_click('a[href$="/examples/example_logs/ReadMe/"]')
10 | self.assert_text("Dashboard / Reports", "h1")
11 | self.js_click('a[href$="/seleniumbase/console_scripts/ReadMe/"]')
12 | self.assert_text("Console Scripts", "h1")
13 | self.js_click('a[href$="/help_docs/syntax_formats/"]')
14 | self.assert_text("Syntax Formats", "h1")
15 | self.js_click('a[href$="/recorder_mode/"]')
16 | self.assert_text("Recorder Mode", "h1")
17 | self.js_click('a[href$="/method_summary/"]')
18 | self.assert_text("API Reference", "h1")
19 | self.js_click('a[href$="/uc_mode/"]')
20 | self.assert_text("UC Mode", "h1")
21 | self.click('img[alt="logo"]')
22 | self.assert_text("SeleniumBase", "h1")
23 |
--------------------------------------------------------------------------------
/examples/test_double_click.py:
--------------------------------------------------------------------------------
1 | """Test double_click() after switching into iframes."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class DoubleClickTests(BaseCase):
7 | def test_switch_to_frame_and_double_click(self):
8 | self.open("https://seleniumbase.io/w3schools/double_click")
9 | self.assert_title("Double Click Testing")
10 | self.click("button#runbtn")
11 | self.switch_to_frame("iframe#iframeResult")
12 | self.double_click('[ondblclick="myFunction()"]')
13 | self.assert_text("Hello World", "#demo")
14 |
15 | def test_switch_to_frame_of_element_and_double_click(self):
16 | self.open("https://seleniumbase.io/w3schools/double_click")
17 | self.assert_title("Double Click Testing")
18 | self.click("button#runbtn")
19 | self.switch_to_frame_of_element('[ondblclick="myFunction()"]')
20 | self.double_click('[ondblclick="myFunction()"]')
21 | self.assert_text("Hello World", "#demo")
22 |
--------------------------------------------------------------------------------
/examples/test_drag_and_drop.py:
--------------------------------------------------------------------------------
1 | """Test drag_and_drop() on different pages."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class DragAndDropTests(BaseCase):
7 | def test_drag_and_drop(self):
8 | self.open("https://seleniumbase.io/other/drag_and_drop")
9 | self.assert_element_not_visible("#div1 img#drag1")
10 | self.drag_and_drop("#drag1", "#div1")
11 | self.assert_element("#div1 img#drag1")
12 | self.sleep(0.8)
13 |
14 | def test_w3schools_drag_and_drop(self):
15 | self.open("https://seleniumbase.io/w3schools/drag_drop")
16 | self.assert_url_contains("drag_drop")
17 | self.click("button#runbtn")
18 | self.switch_to_frame("iframeResult")
19 | self.assert_element_not_visible("#div1 img#drag1")
20 | self.drag_and_drop("#drag1", "#div1")
21 | self.assert_element("#div1 img#drag1")
22 | self.sleep(0.8)
23 |
--------------------------------------------------------------------------------
/examples/test_error_page.py:
--------------------------------------------------------------------------------
1 | """Test an error page with the "highlight() command, which uses a
2 | JavaScript animation to point out page objects that are found.
3 | If an element isn't visible, the test fails with an exception."""
4 | from seleniumbase import BaseCase
5 | BaseCase.main(__name__, __file__)
6 |
7 |
8 | class ErrorPageTests(BaseCase):
9 | def test_error_page(self):
10 | self.open("https://seleniumbase.io/error_page/")
11 | self.highlight('img[alt="500 Error"]')
12 | self.highlight("img#parallax_octocat")
13 | self.highlight("#parallax_error_text")
14 | self.highlight('img[alt*="404"]')
15 | self.highlight("img#octobi_wan_catnobi")
16 | self.highlight("img#speeder")
17 | self.save_screenshot_after_test = True
18 |
--------------------------------------------------------------------------------
/examples/test_fail.py:
--------------------------------------------------------------------------------
1 | """ This test fails on purpose to demonstrate
2 | the logging capabilities of SeleniumBase.
3 | >>> pytest test_fail.py --html=report.html
4 | This creates ``report.html`` with details.
5 | (Also find log files in ``latest_logs/``)"""
6 | import pytest
7 | from seleniumbase import BaseCase
8 | BaseCase.main(__name__, __file__)
9 |
10 |
11 | class FailingTests(BaseCase):
12 | @pytest.mark.expected_failure
13 | def test_find_army_of_robots_on_xkcd_desert_island(self):
14 | self.open("https://xkcd.com/731/")
15 | print("\n(This test should fail)")
16 | self.assert_element("div#ARMY_OF_ROBOTS", timeout=1)
17 |
--------------------------------------------------------------------------------
/examples/test_get_coffee.py:
--------------------------------------------------------------------------------
1 | """Use SeleniumBase to get coffee"""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class GetCoffeeTest(BaseCase):
7 | def test_get_coffee(self):
8 | self.open("https://seleniumbase.io/coffee/")
9 | self.assert_title("Coffee Cart")
10 | self.assert_exact_text("cart (0)", 'a[aria-label="Cart page"]')
11 | self.assert_element('div[data-sb="Mocha"]')
12 | self.click('div[data-sb="Mocha"]')
13 | self.assert_link_text("cart (1)")
14 | self.click_link_text("cart (1)")
15 | self.assert_exact_text("Total: $8.00", "button.pay")
16 | self.click("button.pay")
17 | self.type("input#name", "Selenium Coffee")
18 | self.type("input#email", "test@test.test")
19 | self.click("button#submit-payment")
20 | self.assert_text("Thanks", "#app div.success")
21 |
--------------------------------------------------------------------------------
/examples/test_get_locale_code.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class LocaleTests(BaseCase):
6 | def test_get_locale_code(self):
7 | self.open("about:blank")
8 | locale_code = self.get_locale_code()
9 | message = '\nLocale Code = "%s"' % locale_code
10 | print(message)
11 | self.set_messenger_theme(theme="flat", location="top_center")
12 | self.post_message(message, duration=4)
13 |
--------------------------------------------------------------------------------
/examples/test_get_pdf_text.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class PdfTests(BaseCase):
6 | def test_get_pdf_text(self):
7 | self.open("data:,")
8 | pdf = (
9 | "https://nostarch.com/download/"
10 | "Automate_the_Boring_Stuff_sample_ch17.pdf"
11 | )
12 | pdf_text = self.get_pdf_text(pdf, page=1)
13 | print("\n" + pdf_text)
14 |
--------------------------------------------------------------------------------
/examples/test_get_swag.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyTestClass(BaseCase):
6 | def test_swag_labs(self):
7 | self.open("https://www.saucedemo.com")
8 | self.type("#user-name", "standard_user")
9 | self.type("#password", "secret_sauce\n")
10 | self.assert_element("div.inventory_list")
11 | self.click('button[name*="backpack"]')
12 | self.click("#shopping_cart_container a")
13 | self.assert_text("Backpack", "div.cart_item")
14 | self.click("button#checkout")
15 | self.type("input#first-name", "SeleniumBase")
16 | self.type("input#last-name", "Automation")
17 | self.type("input#postal-code", "77123")
18 | self.click("input#continue")
19 | self.click("button#finish")
20 | self.assert_text("Thank you for your order!")
21 |
--------------------------------------------------------------------------------
/examples/test_get_user_agent.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class UserAgentTests(BaseCase):
6 | def test_get_user_agent(self):
7 | self.open("data:,")
8 | user_agent = self.get_user_agent()
9 | print('\nUser Agent = "%s"' % user_agent)
10 | self.set_messenger_theme(theme="flat", location="top_center")
11 | self.post_message(user_agent, duration=4)
12 |
--------------------------------------------------------------------------------
/examples/test_highlight_elements.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class HighlightTest(BaseCase):
6 | def test_highlight_inputs(self):
7 | self.open("https://seleniumbase.io/demo_page")
8 | if self.headed:
9 | self.highlight_elements("input", loops=2) # Default: 4
10 | else:
11 | self.highlight_elements("input", loops=1, limit=3)
12 |
--------------------------------------------------------------------------------
/examples/test_inspect_html.py:
--------------------------------------------------------------------------------
1 | """Uses the SeleniumBase implementation of HTML-Inspector to inspect the HTML.
2 | See https://github.com/philipwalton/html-inspector for more details.
3 | (Only works on Chrome and Chromium-based browsers.)"""
4 | from seleniumbase import BaseCase
5 | BaseCase.main(__name__, __file__)
6 |
7 |
8 | class HtmlInspectorTests(BaseCase):
9 | def test_html_inspector(self):
10 | self.open("https://xkcd.com/1144/")
11 | self.inspect_html()
12 |
--------------------------------------------------------------------------------
/examples/test_login.py:
--------------------------------------------------------------------------------
1 | """A SeleniumBase test for verifying Login functionality on Swag Labs."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class SwagLabsLoginTests(BaseCase):
7 | def login_to_swag_labs(self):
8 | self.open("https://www.saucedemo.com")
9 | self.wait_for_element("div.login_logo")
10 | self.type("#user-name", "standard_user")
11 | self.type("#password", "secret_sauce")
12 | self.click('input[type="submit"]')
13 |
14 | def test_swag_labs_login(self):
15 | self.login_to_swag_labs()
16 | self.assert_element("div.inventory_list")
17 | self.assert_element('.inventory_item:contains("Backpack")')
18 | self.js_click("a#logout_sidebar_link")
19 | self.assert_element("div#login_button_container")
20 |
--------------------------------------------------------------------------------
/examples/test_mfa_login.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class TestMFALogin(BaseCase):
6 | def test_mfa_login(self):
7 | self.open("https://seleniumbase.io/realworld/login")
8 | self.type("#username", "demo_user")
9 | self.type("#password", "secret_pass")
10 | self.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") # 6-digit
11 | self.assert_text("Welcome!", "h1")
12 | self.highlight("img#image1") # A fancier assert_element() call
13 | self.click('a:contains("This Page")') # Use :contains() on any tag
14 | self.save_screenshot_to_logs() # ("./latest_logs" folder for test)
15 | self.click_link("Sign out") # Link must be "a" tag. Not "button".
16 | self.assert_element('a:contains("Sign in")')
17 | self.assert_exact_text("You have been signed out!", "#top_message")
18 |
--------------------------------------------------------------------------------
/examples/test_multiple_drivers.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MultipleDriversTest(BaseCase):
6 | def test_multiple_drivers(self):
7 | if self.browser == "safari":
8 | self.open_if_not_url("about:blank")
9 | print("\n Safari doesn't support multiple drivers.")
10 | self.skip("Safari doesn't support multiple drivers.")
11 | self.open("data:text/html,Driver 1 ")
12 | driver2 = self.get_new_driver()
13 | self.open("data:text/html,Driver 2 ")
14 | self.switch_to_default_driver() # Driver 1
15 | self.highlight("h1")
16 | self.assert_text("Driver 1", "h1")
17 | self.switch_to_driver(driver2) # Driver 2
18 | self.highlight("h1")
19 | self.assert_text("Driver 2", "h1")
20 |
--------------------------------------------------------------------------------
/examples/test_null.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class NullTests(BaseCase):
6 | def test_null(self):
7 | pass
8 |
--------------------------------------------------------------------------------
/examples/test_pdf_asserts.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class PdfAssertTests(BaseCase):
6 | def test_assert_pdf_text(self):
7 | self.open("data:,")
8 | # Assert PDF contains the expected text on Page 1
9 | self.assert_pdf_text(
10 | "https://nostarch.com/download/Automate_the_Boring_Stuff_dTOC.pdf",
11 | "Programming Is a Creative Activity",
12 | page=1,
13 | )
14 |
15 | # Assert PDF contains the expected text on any of the pages
16 | self.assert_pdf_text(
17 | "https://nostarch.com/download/Automate_the_Boring_Stuff_dTOC.pdf",
18 | "Extracting Text from PDFs",
19 | )
20 |
--------------------------------------------------------------------------------
/examples/test_pytest_parametrize.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 |
4 | @pytest.mark.parametrize(
5 | "value", ["List of Features", "Command Line Options"]
6 | )
7 | def test_sb_fixture_with_no_class(sb, value):
8 | sb.open("seleniumbase.io/help_docs/install/")
9 | sb.type('input[aria-label="Search"]', value)
10 | sb.click("nav h1 mark")
11 | sb.assert_title_contains(value)
12 | sb.assert_text(value, "div.md-content")
13 |
14 |
15 | class Test_SB_Fixture:
16 | @pytest.mark.parametrize(
17 | "value", ["Console Scripts", "API Reference"]
18 | )
19 | def test_sb_fixture_inside_class(self, sb, value):
20 | sb.open("seleniumbase.io/help_docs/install/")
21 | sb.type('input[aria-label="Search"]', value)
22 | sb.click("nav h1 mark")
23 | sb.assert_title_contains(value)
24 | sb.assert_text(value, "div.md-content")
25 |
--------------------------------------------------------------------------------
/examples/test_request_sb_fixture.py:
--------------------------------------------------------------------------------
1 | # Use the pytest "request" fixture to get the "sb" fixture (no class)
2 | def test_request_sb_fixture(request):
3 | sb = request.getfixturevalue("sb")
4 | sb.open("https://seleniumbase.io/demo_page")
5 | sb.assert_text("SeleniumBase", "#myForm h2")
6 | sb.assert_element("input#myTextInput")
7 | sb.type("#myTextarea", "This is me")
8 | sb.click("#myButton")
9 | sb.tearDown()
10 |
11 |
12 | # Use the pytest "request" fixture to get the "sb" fixture (in class)
13 | class Test_Request_Fixture:
14 | def test_request_sb_fixture_in_class(self, request):
15 | sb = request.getfixturevalue("sb")
16 | sb.open("https://seleniumbase.io/demo_page")
17 | sb.assert_element("input#myTextInput")
18 | sb.type("#myTextarea", "Automated")
19 | sb.assert_text("This Text is Green", "#pText")
20 | sb.click("#myButton")
21 | sb.assert_text("This Text is Purple", "#pText")
22 | sb.tearDown()
23 |
--------------------------------------------------------------------------------
/examples/test_roblox_mobile.py:
--------------------------------------------------------------------------------
1 | """Mobile device test for Chromium-based browsers
2 | Example: "pytest test_roblox_mobile.py --mobile"
3 | """
4 | from seleniumbase import BaseCase
5 |
6 | if __name__ == "__main__":
7 | from pytest import main
8 | main([__file__, "--mobile", "-s"])
9 |
10 |
11 | class RobloxTests(BaseCase):
12 | def test_roblox_mobile_site(self):
13 | if not self.mobile_emulator:
14 | self.open_if_not_url("about:blank")
15 | print("\n This test is only for mobile-device web browsers!")
16 | print(' (Use "--mobile" to run this test in Mobile Mode!)')
17 | self.skip('Use "--mobile" to run this test in Mobile Mode!')
18 | self.open("https://www.roblox.com/")
19 | self.assert_element("#download-the-app-container")
20 | self.assert_text("Roblox for Android", "p.roblox-for-platform")
21 | self.assert_text("Continue in App", "a.primary-link")
22 | self.highlight("p.roblox-for-platform", loops=8)
23 | self.highlight("a.primary-link", loops=8)
24 |
--------------------------------------------------------------------------------
/examples/test_sb_fixture.py:
--------------------------------------------------------------------------------
1 | # "sb" pytest fixture test in a method with no class
2 | def test_sb_fixture_with_no_class(sb):
3 | sb.open("seleniumbase.io/help_docs/install/")
4 | sb.type('input[aria-label="Search"]', "GUI Commander")
5 | sb.click('mark:contains("Commander")')
6 | sb.assert_title_contains("GUI / Commander")
7 |
8 |
9 | # "sb" pytest fixture test in a method inside a class
10 | class Test_SB_Fixture:
11 | def test_sb_fixture_inside_class(self, sb):
12 | sb.open("seleniumbase.io/help_docs/install/")
13 | sb.type('input[aria-label="Search"]', "GUI Commander")
14 | sb.click('mark:contains("Commander")')
15 | sb.assert_title_contains("GUI / Commander")
16 |
--------------------------------------------------------------------------------
/examples/test_simple_login.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class TestSimpleLogin(BaseCase):
6 | def test_simple_login(self):
7 | self.open("seleniumbase.io/simple/login")
8 | self.type("#username", "demo_user")
9 | self.type("#password", "secret_pass")
10 | self.click('a:contains("Sign in")')
11 | self.assert_exact_text("Welcome!", "h1")
12 | self.assert_element("img#image1")
13 | self.highlight("#image1")
14 | self.click_link("Sign out")
15 | self.assert_text("signed out", "#top_message")
16 |
--------------------------------------------------------------------------------
/examples/test_suite.py:
--------------------------------------------------------------------------------
1 | """This test suite contains 2 passing tests and 2 failing tests."""
2 | import pytest
3 | from seleniumbase import BaseCase
4 | BaseCase.main(__name__, __file__)
5 |
6 |
7 | class MyTestSuite(BaseCase):
8 | def test_1(self):
9 | self.open("https://xkcd.com/1722/")
10 | self.assert_text("Debugging", "div#ctitle", timeout=4)
11 | for p in range(3):
12 | self.click('a[rel="next"]')
13 | self.assert_text("Linear Regression", "div#ctitle", timeout=4)
14 |
15 | @pytest.mark.expected_failure
16 | def test_2(self):
17 | print("\n(This test should fail)")
18 | self.open("https://xkcd.com/1373/")
19 | self.assert_text("FakeText", "div#ctitle", timeout=0.4)
20 |
21 | def test_3(self):
22 | self.open("https://xkcd.com/2224/")
23 | self.assert_text("Software Updates", "div#ctitle", timeout=4)
24 | self.open("https://xkcd.com/608/")
25 | self.assert_exact_text("Form", "div#ctitle", timeout=4)
26 |
27 | @pytest.mark.expected_failure
28 | def test_4(self):
29 | print("\n(This test should fail)")
30 | self.open("https://xkcd.com/2224/")
31 | self.assert_element("FakeElement.DoesNotExist", timeout=0.4)
32 |
--------------------------------------------------------------------------------
/examples/test_url_asserts.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class URLTestClass(BaseCase):
6 | def test_url_asserts(self):
7 | self.open("https://seleniumbase.io/help_docs/how_it_works/")
8 | self.assert_url("https://seleniumbase.io/help_docs/how_it_works/")
9 | self.assert_title_contains("How it Works")
10 | self.js_click('nav a:contains("Coffee Cart")')
11 | self.assert_url_contains("/coffee")
12 | self.assert_title("Coffee Cart")
13 |
--------------------------------------------------------------------------------
/examples/test_usefixtures.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 |
4 | @pytest.mark.usefixtures("sb")
5 | class Test_UseFixtures:
6 | def test_usefixtures_on_class(self):
7 | if not hasattr(self, "sb"):
8 | print("This test is for pytest only!")
9 | return
10 | sb = self.sb
11 | sb.open("https://seleniumbase.io/realworld/login")
12 | sb.type("#username", "demo_user")
13 | sb.type("#password", "secret_pass")
14 | sb.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") # 6-digit
15 | sb.assert_text("Welcome!", "h1")
16 | sb.highlight("img#image1") # A fancier assert_element() call
17 | sb.click('a:contains("This Page")') # Use :contains() on any tag
18 | sb.save_screenshot_to_logs() # In "./latest_logs/" folder.
19 | sb.click_link("Sign out") # Link must be "a" tag. Not "button".
20 | sb.assert_element('a:contains("Sign in")')
21 | sb.assert_exact_text("You have been signed out!", "#top_message")
22 |
--------------------------------------------------------------------------------
/examples/test_window_switching.py:
--------------------------------------------------------------------------------
1 | """
2 | Sometimes tests open new tabs/windows, and you'll need
3 | to switch to them first in order to interact with them.
4 | The starting window is window(0). Then increments by 1.
5 | """
6 | from seleniumbase import BaseCase
7 | BaseCase.main(__name__, __file__)
8 |
9 |
10 | class TabSwitchingTests(BaseCase):
11 | def test_switch_to_tabs(self):
12 | self.open("data:text/html,Page A ")
13 | self.assert_text("Page A")
14 | self.open_new_window()
15 | self.open("data:text/html,Page B ")
16 | self.assert_text("Page B")
17 | self.switch_to_window(0)
18 | self.assert_text("Page A")
19 | self.assert_text_not_visible("Page B")
20 | self.switch_to_window(1)
21 | self.assert_text("Page B")
22 | self.assert_text_not_visible("Page A")
23 |
--------------------------------------------------------------------------------
/examples/test_xfail.py:
--------------------------------------------------------------------------------
1 | """Testing the @pytest.mark.xfail marker.
2 | https://docs.pytest.org/en/latest/skipping.html
3 | (The test is expected to fail, but don't fail the entire build for it.)"""
4 | import pytest
5 | from seleniumbase import BaseCase
6 | BaseCase.main(__name__, __file__)
7 |
8 |
9 | class XFailTests(BaseCase):
10 | @pytest.mark.xfail
11 | def test_xfail(self):
12 | self.open("https://xkcd.com/376/")
13 | self.sleep(1) # Time to read the comic
14 | self.fail("There is a known bug here!")
15 |
--------------------------------------------------------------------------------
/examples/test_xkcd.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyTestClass(BaseCase):
6 | def test_xkcd(self):
7 | self.open("https://xkcd.com/353/")
8 | self.assert_title("xkcd: Python")
9 | self.assert_element('img[alt="Python"]')
10 | self.click('a[rel="license"]')
11 | self.assert_text("free to copy and reuse")
12 | self.go_back()
13 | self.click_link("About")
14 | self.assert_exact_text("xkcd.com", "h2")
15 | self.click_link("comic #249")
16 | self.assert_element('img[alt*="Chess"]')
17 |
--------------------------------------------------------------------------------
/examples/tour_examples/bootstrap_xkcd_tour.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyTestClass(BaseCase):
6 | def test_bootstrap_tour(self):
7 | self.open("https://xkcd.com/1117/")
8 | self.assert_element('img[alt="My Sky"]')
9 | self.create_bootstrap_tour()
10 | self.add_tour_step("Welcome to XKCD!")
11 | self.add_tour_step("This is the XKCD logo.", "#masthead img")
12 | self.add_tour_step("Here's the daily webcomic.", "#comic img")
13 | self.add_tour_step("This is the title.", "#ctitle", alignment="top")
14 | self.add_tour_step("Click here for the next comic.", 'a[rel="next"]')
15 | self.add_tour_step("Click here for the previous one.", 'a[rel="prev"]')
16 | self.add_tour_step("Learn about the author here.", 'a[rel="author"]')
17 | self.add_tour_step("Click for a random comic.", 'a[href*="/random/"]')
18 | self.add_tour_step("Thanks for taking this tour!")
19 | self.export_tour(filename="bootstrap_xkcd_tour.js")
20 | self.play_tour()
21 |
--------------------------------------------------------------------------------
/examples/tour_examples/octocat_tour.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyTourClass(BaseCase):
6 | def test_octocat_tour(self):
7 | self.maximize_window()
8 | self.open("https://seleniumbase.io/error_page/")
9 | self.wait_for_element("#parallax_octocat")
10 | self.create_tour(theme="bootstrap")
11 | self.add_tour_step("Welcome to the Octocat Tour!")
12 | self.add_tour_step("This is Octocat", "#parallax_octocat")
13 | self.add_tour_step("This is Octobi-Wan Catnobi", "#octobi_wan_catnobi")
14 | self.add_tour_step("Ooops!!! ", "#parallax_error_text")
15 | self.add_tour_step("This is a Star Wars speeder.", "#speeder")
16 | self.add_tour_step("This is a sign with a 500-Error", "#parallax_sign")
17 | self.add_tour_step(
18 | "This is not the page you're looking for.", 'img[alt*="404"]'
19 | )
20 | self.add_tour_step("Have a great day! ", title="😃 ☀️ 😁")
21 | self.add_tour_step("And may the Force be with you! ", title="⭐")
22 | self.export_tour(filename="octocat_tour.js")
23 | self.play_tour()
24 |
--------------------------------------------------------------------------------
/examples/tour_examples/xkcd_tour.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyTestClass(BaseCase):
6 | def test_create_tour(self):
7 | self.open("https://xkcd.com/1117/")
8 | self.assert_element('img[alt="My Sky"]')
9 | self.create_tour(theme="dark")
10 | self.add_tour_step("Welcome to XKCD!")
11 | self.add_tour_step("This is the XKCD logo.", "#masthead img")
12 | self.add_tour_step("Here's the daily webcomic.", "#comic img")
13 | self.add_tour_step("This is the title.", "#ctitle", alignment="top")
14 | self.add_tour_step("Click here for the next comic.", 'a[rel="next"]')
15 | self.add_tour_step("Click here for the previous one.", 'a[rel="prev"]')
16 | self.add_tour_step("Learn about the author here.", 'a[rel="author"]')
17 | self.add_tour_step("Click here for the license.", 'a[rel="license"]')
18 | self.add_tour_step("Click for a random comic.", 'a[href*="/random/"]')
19 | self.add_tour_step("Thanks for taking this tour!")
20 | self.export_tour(filename="xkcd_tour.js")
21 | self.play_tour()
22 |
--------------------------------------------------------------------------------
/examples/translations/chinese_test_1.py:
--------------------------------------------------------------------------------
1 | # Chinese Language Test
2 | from seleniumbase.translate.chinese import 硒测试用例
3 | 硒测试用例.main(__name__, __file__)
4 |
5 |
6 | class 我的测试类(硒测试用例):
7 | def test_例子1(self):
8 | self.开启("https://zh.wikipedia.org/wiki/")
9 | self.断言标题("维基百科,自由的百科全书")
10 | self.断言元素('a[title="Wikipedia:关于"]')
11 | self.如果可见请单击('button[aria-label="关闭"]')
12 | self.如果可见请单击('button[aria-label="關閉"]')
13 | self.断言元素('span:contains("创建账号")')
14 | self.断言元素('span:contains("登录")')
15 | self.输入文本('input[name="search"]', "舞龍")
16 | self.单击('button:contains("搜索")')
17 | self.断言文本("舞龍", "#firstHeading")
18 | self.断言元素('img[src*="Chinese_draak.jpg"]')
19 | self.回去()
20 | self.输入文本('input[name="search"]', "麻婆豆腐")
21 | self.单击('button:contains("搜索")')
22 | self.断言文本("麻婆豆腐", "#firstHeading")
23 | self.断言元素('figure:contains("一家中餐館的麻婆豆腐")')
24 | self.回去()
25 | self.输入文本('input[name="search"]', "精武英雄")
26 | self.单击('button:contains("搜索")')
27 | self.断言元素('img[src*="Fist_of_legend.jpg"]')
28 | self.断言文本("李连杰", 'li a[title="李连杰"]')
29 |
--------------------------------------------------------------------------------
/examples/translations/dutch_test_1.py:
--------------------------------------------------------------------------------
1 | # Dutch Language Test
2 | from seleniumbase.translate.dutch import Testgeval
3 | Testgeval.main(__name__, __file__)
4 |
5 |
6 | class MijnTestklasse(Testgeval):
7 | def test_voorbeeld_1(self):
8 | self.openen("https://nl.wikipedia.org/wiki/Hoofdpagina")
9 | self.controleren_element('a[title*="Welkom voor nieuwkomers"]')
10 | self.controleren_tekst("Welkom op Wikipedia", "td.hp-welkom")
11 | self.typ("#searchform input", "Stroopwafel")
12 | self.klik("#searchform button")
13 | self.controleren_tekst("Stroopwafel", "#firstHeading")
14 | self.controleren_element('img[src*="Stroopwafels"]')
15 | self.typ("#searchform input", "Rijksmuseum Amsterdam")
16 | self.klik("#searchform button")
17 | self.controleren_tekst("Rijksmuseum", "#firstHeading")
18 | self.controleren_element('img[src*="Rijksmuseum"]')
19 | self.terug()
20 | self.controleren_url_bevat("Stroopwafel")
21 | self.vooruit()
22 | self.controleren_url_bevat("Rijksmuseum")
23 |
--------------------------------------------------------------------------------
/examples/translations/english_test_1.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class MyTestClass(BaseCase):
6 | def test_example_1(self):
7 | self.open("https://www.saucedemo.com")
8 | self.type("#user-name", "standard_user")
9 | self.type("#password", "secret_sauce\n")
10 | self.assert_element("#inventory_container")
11 | self.assert_exact_text("Products", "span.title")
12 | self.click('button[name*="backpack"]')
13 | self.click("#shopping_cart_container a")
14 | self.assert_exact_text("Your Cart", "span.title")
15 | self.assert_text("Backpack", "div.cart_item")
16 | self.click('button:contains("Remove")') # HTML innerText
17 | self.assert_text_not_visible("Backpack", "div.cart_item")
18 | self.js_click("a#logout_sidebar_link")
19 |
--------------------------------------------------------------------------------
/examples/translations/french_test_1.py:
--------------------------------------------------------------------------------
1 | # French Language Test
2 | from seleniumbase.translate.french import CasDeBase
3 | CasDeBase.main(__name__, __file__)
4 |
5 |
6 | class MaClasseDeTest(CasDeBase):
7 | def test_exemple_1(self):
8 | self.ouvrir("https://fr.wikipedia.org/wiki/")
9 | self.vérifier_texte("Wikipédia")
10 | self.vérifier_élément('[alt="Wikipédia"]')
11 | self.cliquer_si_affiché('button[aria-label="Fermer"]')
12 | self.js_taper("#searchform input", "Crème brûlée")
13 | self.cliquer("#searchform button")
14 | self.vérifier_texte("Crème brûlée", "#firstHeading")
15 | self.vérifier_élément('img[alt*="Crème brûlée"]')
16 | self.js_taper("#searchform input", "Jardin des Tuileries")
17 | self.cliquer("#searchform button")
18 | self.vérifier_texte("Jardin des Tuileries", "#firstHeading")
19 | self.vérifier_élément('img[alt*="Jardin des Tuileries"]')
20 | self.retour()
21 | self.vérifier_url_contient("brûlée")
22 | self.en_avant()
23 | self.vérifier_url_contient("Jardin")
24 |
--------------------------------------------------------------------------------
/examples/translations/italian_test_1.py:
--------------------------------------------------------------------------------
1 | # Italian Language Test
2 | from seleniumbase.translate.italian import CasoDiProva
3 | CasoDiProva.main(__name__, __file__)
4 |
5 |
6 | class MiaClasseDiTest(CasoDiProva):
7 | def test_esempio_1(self):
8 | self.apri("https://it.wikipedia.org/wiki/")
9 | self.verificare_testo("Wikipedia")
10 | self.verificare_elemento('a[title="Lingua italiana"]')
11 | self.digitare('input[name="search"]', "Pizza")
12 | self.fare_clic("#searchform button")
13 | self.verificare_testo("Pizza", "#firstHeading")
14 | self.verificare_elemento('figure img[src*="pizza"]')
15 | self.digitare('input[name="search"]', "Colosseo")
16 | self.fare_clic("#searchform button")
17 | self.verificare_testo("Colosseo", "#firstHeading")
18 | self.verificare_elemento('figure img[src*="Colosseo"]')
19 | self.indietro()
20 | self.verificare_url_contiene("Pizza")
21 | self.avanti()
22 | self.verificare_url_contiene("Colosseo")
23 |
--------------------------------------------------------------------------------
/examples/translations/japanese_test_1.py:
--------------------------------------------------------------------------------
1 | # Japanese Language Test
2 | from seleniumbase.translate.japanese import セレニウムテストケース
3 | セレニウムテストケース.main(__name__, __file__)
4 |
5 |
6 | class 私のテストクラス(セレニウムテストケース):
7 | def test_例1(self):
8 | self.を開く("https://ja.wikipedia.org/wiki/")
9 | self.テキストを確認する("ウィキペディア")
10 | self.要素を確認する('[title*="ウィキペディアへようこそ"]')
11 | self.JS入力('input[name="search"]', "アニメ")
12 | self.クリックして("#searchform button")
13 | self.テキストを確認する("アニメ", "#firstHeading")
14 | self.JS入力('input[name="search"]', "寿司")
15 | self.クリックして("#searchform button")
16 | self.テキストを確認する("寿司", "#firstHeading")
17 | self.要素を確認する('img[src*="Various_sushi"]')
18 | self.JS入力("#searchInput", "レゴランド・ジャパン")
19 | self.クリックして("#searchform button")
20 | self.要素を確認する('img[src*="LEGOLAND_JAPAN"]')
21 | self.リンクテキストを確認する("名古屋城")
22 | self.リンクテキストをクリックします("テーマパーク")
23 | self.テキストを確認する("テーマパーク", "#firstHeading")
24 |
--------------------------------------------------------------------------------
/examples/translations/korean_test_1.py:
--------------------------------------------------------------------------------
1 | # Korean Language Test
2 | from seleniumbase.translate.korean import 셀레늄_테스트_케이스
3 | 셀레늄_테스트_케이스.main(__name__, __file__)
4 |
5 |
6 | class 테스트_클래스(셀레늄_테스트_케이스):
7 | def test_실시예_1(self):
8 | self.열기("https://ko.wikipedia.org/wiki/")
9 | self.텍스트_확인("위키백과")
10 | self.요소_확인('[title="위키백과:소개"]')
11 | self.JS_입력("#searchform input", "김치")
12 | self.클릭("#searchform button")
13 | self.텍스트_확인("김치", "#firstHeading")
14 | self.요소_확인('img[src*="Various_kimchi.jpg"]')
15 | self.링크_텍스트_확인("한국 요리")
16 | self.JS_입력("#searchform input", "비빔밥")
17 | self.클릭("#searchform button")
18 | self.텍스트_확인("비빔밥", "#firstHeading")
19 | self.요소_확인('img[src*="Dolsot-bibimbap.jpg"]')
20 | self.링크_텍스트를_클릭합니다("돌솥비빔밥")
21 | self.텍스트_확인("돌솥비빔밥", "#firstHeading")
22 |
--------------------------------------------------------------------------------
/examples/translations/portuguese_test_1.py:
--------------------------------------------------------------------------------
1 | # Portuguese Language Test
2 | from seleniumbase.translate.portuguese import CasoDeTeste
3 | CasoDeTeste.main(__name__, __file__)
4 |
5 |
6 | class MinhaClasseDeTeste(CasoDeTeste):
7 | def test_exemplo_1(self):
8 | self.abrir("https://pt.wikipedia.org/wiki/")
9 | self.verificar_texto("Wikipédia")
10 | self.verificar_elemento('[title="Língua portuguesa"]')
11 | self.digitar("#searchform input", "João Pessoa")
12 | self.clique("#searchform button")
13 | self.verificar_texto("João Pessoa", "#firstHeading")
14 | self.verificar_elemento('img[alt*="João Pessoa"]')
15 | self.digitar("#searchform input", "Florianópolis")
16 | self.clique("#searchform button")
17 | self.verificar_texto("Florianópolis", "h1#firstHeading")
18 | self.verificar_elemento('td:contains("Avenida Beira-Mar")')
19 | self.voltar()
20 | self.verificar_url_contém("João_Pessoa")
21 | self.atualizar_a_página()
22 | self.js_digitar("#searchform input", "Teatro Amazonas")
23 | self.clique("#searchform button")
24 | self.verificar_texto("Teatro Amazonas", "#firstHeading")
25 | self.verificar_texto_do_link("Festival Amazonas de Ópera")
26 |
--------------------------------------------------------------------------------
/examples/translations/russian_test_1.py:
--------------------------------------------------------------------------------
1 | # Russian Language Test
2 | from seleniumbase.translate.russian import ТестНаСелен
3 | ТестНаСелен.main(__name__, __file__)
4 |
5 |
6 | class МойТестовыйКласс(ТестНаСелен):
7 | def test_пример_1(self):
8 | self.открыть("https://ru.wikipedia.org/wiki/")
9 | self.подтвердить_элемент('[title="Русский язык"]')
10 | self.подтвердить_текст("Википедия", "div.main-wikimedia-header")
11 | self.введите("#searchInput", "МГУ")
12 | self.нажмите("#searchButton")
13 | self.подтвердить_текст("университет", "#firstHeading")
14 | self.подтвердить_элемент('img[alt*="Главное здание МГУ"]')
15 | self.введите("#searchInput", "приключения Шурика")
16 | self.нажмите("#searchButton")
17 | self.подтвердить_текст("Операция «Ы» и другие приключения Шурика")
18 | self.подтвердить_элемент('img[alt="Постер фильма"]')
19 | self.назад()
20 | self.подтвердить_URL_содержит("университет")
21 | self.вперед()
22 | self.подтвердить_URL_содержит("Шурика")
23 |
--------------------------------------------------------------------------------
/examples/translations/spanish_test_1.py:
--------------------------------------------------------------------------------
1 | # Spanish Language Test
2 | from seleniumbase.translate.spanish import CasoDePrueba
3 | CasoDePrueba.main(__name__, __file__)
4 |
5 |
6 | class MiClaseDePrueba(CasoDePrueba):
7 | def test_ejemplo_1(self):
8 | self.abrir("https://es.wikipedia.org/wiki/")
9 | self.verificar_texto("Wikipedia")
10 | self.verificar_elemento('[title="Wikipedia:Bienvenidos"]')
11 | self.escriba('[name="search"]', "Parque de Atracciones Tibidabo")
12 | self.haga_clic('button:contains("Buscar")')
13 | self.verificar_texto("Tibidabo", "#firstHeading")
14 | self.verificar_elemento('img[src*="Tibidabo"]')
15 | self.escriba('input[name="search"]', "Palma de Mallorca")
16 | self.haga_clic('button:contains("Buscar")')
17 | self.verificar_texto("Palma de Mallorca", "#firstHeading")
18 | self.verificar_elemento('img[src*="Palma"]')
19 | self.volver()
20 | self.verificar_url_contiene("Tibidabo")
21 | self.adelante()
22 | self.verificar_url_contiene("Mallorca")
23 |
--------------------------------------------------------------------------------
/examples/uc_cdp_events.py:
--------------------------------------------------------------------------------
1 | from rich.pretty import pprint
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__, "--uc", "--uc-cdp")
4 |
5 |
6 | class CDPTests(BaseCase):
7 | def add_cdp_listener(self):
8 | # (To print everything, use "*". Otherwise select specific headers.)
9 | # self.driver.add_cdp_listener("*", lambda data: print(pformat(data)))
10 | self.driver.add_cdp_listener(
11 | "Network.requestWillBeSentExtraInfo",
12 | lambda data: pprint(data)
13 | )
14 |
15 | def click_turnstile_and_verify(sb):
16 | sb.uc_gui_handle_captcha()
17 | sb.assert_element("img#captcha-success", timeout=3)
18 | sb.highlight("img#captcha-success", loops=8)
19 |
20 | def test_display_cdp_events(self):
21 | if not (self.undetectable and self.uc_cdp_events):
22 | self.get_new_driver(undetectable=True, uc_cdp_events=True)
23 | url = "seleniumbase.io/apps/turnstile"
24 | self.uc_open_with_reconnect(url, 2)
25 | self.add_cdp_listener()
26 | self.click_turnstile_and_verify()
27 | self.sleep(1)
28 | self.refresh()
29 | self.sleep(1.2)
30 |
--------------------------------------------------------------------------------
/examples/unit_tests/ReadMe.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ### pytest-specific unit tests
4 |
5 | The tests in this folder are for basic verification of the SeleniumBase framework with pytest.
6 |
--------------------------------------------------------------------------------
/examples/upload_file_test.py:
--------------------------------------------------------------------------------
1 | """Testing the self.choose_file() and self.assert_attribute() methods."""
2 | import os
3 | from seleniumbase import BaseCase
4 | BaseCase.main(__name__, __file__)
5 |
6 |
7 | class FileUploadButtonTests(BaseCase):
8 | def test_file_upload_button(self):
9 | self.open("https://seleniumbase.io/w3schools/file_upload")
10 | self.click("button#runbtn")
11 | self.switch_to_frame("iframeResult")
12 | zoom_in = 'input[type="file"]{zoom: 1.6;-moz-transform: scale(1.6);}'
13 | self.add_css_style(zoom_in)
14 | self.highlight('input[type="file"]')
15 | dir_name = os.path.dirname(os.path.abspath(__file__))
16 | my_file = "screenshot.png"
17 | file_path = os.path.join(dir_name, "example_logs/%s" % my_file)
18 | self.assert_attribute("#myFile", "value", "")
19 | self.choose_file('input[type="file"]', file_path)
20 | self.assert_attribute("#myFile", "value", "C:\\fakepath\\%s" % my_file)
21 | self.highlight('input[type="file"]')
22 |
--------------------------------------------------------------------------------
/examples/verify_undetected.py:
--------------------------------------------------------------------------------
1 | """Determine if your browser is detectable by anti-bot services.
2 | Some sites use scripts to detect Selenium, and then block you.
3 | To evade detection, add --uc as a pytest command-line option."""
4 | from seleniumbase import BaseCase
5 | BaseCase.main(__name__, __file__, "--uc")
6 |
7 |
8 | class UndetectedTest(BaseCase):
9 | def test_browser_is_undetected(self):
10 | url = "https://gitlab.com/users/sign_in"
11 | if not self.undetectable:
12 | self.get_new_driver(undetectable=True)
13 | self.uc_open_with_reconnect(url)
14 | self.uc_gui_click_captcha()
15 | self.assert_text("Username", '[for="user_login"]', timeout=3)
16 | self.post_message("SeleniumBase wasn't detected", duration=4)
17 | self._print("\n Success! Website did not detect Selenium! ")
18 |
--------------------------------------------------------------------------------
/examples/visual_testing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/examples/visual_testing/__init__.py
--------------------------------------------------------------------------------
/examples/visual_testing/case_plans/layout_test.VisualLayoutTests.test_applitools_layout_change.md:
--------------------------------------------------------------------------------
1 | ``layout_test.py::VisualLayoutTests::test_applitools_layout_change``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://applitools.com/helloworld?diff1. Call ``check_window()`` with ``baseline=True``. Click the button that changes the text of an element. Call ``check_window()`` three times for ``level=1``, ``level=2``, and ``level=3``. | No issues are detected because a text change should not affect ``check_window()`` |
6 | | 2 | Click the button that makes a hidden element visible. Call ``check_window()`` three times for ``level=1``, ``level=2``, and ``level=3``, but wrap the third call with ``self.assert_raises(Exception):``. | No exceptions are raised because the first two calls should pass and the third one was wrapped with ``self.assert_raises(Exception):``. |
7 |
--------------------------------------------------------------------------------
/examples/visual_testing/case_plans/python_home_test.VisualLayoutTests.test_python_home_layout_change.md:
--------------------------------------------------------------------------------
1 | ``python_home_test.py::VisualLayoutTests::test_python_home_layout_change``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://python.org/. Call ``check_window()`` with ``baseline=True``. | |
6 | | 2 | Remove the ``Donate`` button using ``remove_element(SELECTOR)``. Call ``check_window()`` with ``level=0``. | The test detects that the ``Donate`` button was removed. The test does not fail because the check was set to ``level=0`` (print-only). A ``side_by_side_NAME.html`` file appears in the specific ``latest_logs/`` folder of the test. |
7 |
--------------------------------------------------------------------------------
/examples/visual_testing/case_plans/test_layout_fail.VisualLayoutFailureTests.test_applitools_change.md:
--------------------------------------------------------------------------------
1 | ``test_layout_fail.py::VisualLayoutFailureTests::test_applitools_change``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://applitools.com/helloworld?diff1. Call ``check_window()`` with ``baseline=True``. | |
6 | | 2 | Click the button that makes a hidden element visible. Call ``check_window()`` with ``level=3``. | The test fails because the element attribute has changed. A ``side_by_side.html`` file appears in the specific ``latest_logs/`` folder of the test. |
7 |
--------------------------------------------------------------------------------
/examples/visual_testing/case_plans/test_layout_fail.VisualLayoutFailureTests.test_xkcd_logo_change.md:
--------------------------------------------------------------------------------
1 | ``test_layout_fail.py::VisualLayoutFailureTests::test_xkcd_logo_change``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://xkcd.com/554/. Call ``check_window()`` with ``baseline=True``. | |
6 | | 2 | Resize the logo using ``set_attribute()``. Call ``check_window()`` with ``level=3``. | The test fails because the logo has changed. A ``side_by_side.html`` file appears in the specific ``latest_logs/`` folder of the test. |
7 |
--------------------------------------------------------------------------------
/examples/visual_testing/case_plans/test_layout_fail.VisualLayout_FixtureTests.test_python_home_change.md:
--------------------------------------------------------------------------------
1 | ``test_layout_fail.py::VisualLayout_FixtureTests::test_python_home_change``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://python.org/. Call ``check_window()`` with ``baseline=True``. | |
6 | | 2 | Remove the ``Donate`` button using ``remove_element(SELECTOR)``. Call ``check_window()`` with ``level=3``. | The test fails because the ``Donate`` button was removed. A ``side_by_side.html`` file appears in the specific ``latest_logs/`` folder of the test. |
7 |
--------------------------------------------------------------------------------
/examples/visual_testing/case_plans/xkcd_visual_test.VisualLayoutTests.test_xkcd_layout_change.md:
--------------------------------------------------------------------------------
1 | ``xkcd_visual_test.py::VisualLayoutTests::test_xkcd_layout_change``
2 | ---
3 | | # | Step Description | Expected Result |
4 | | - | ---------------- | --------------- |
5 | | 1 | Open https://xkcd.com/554/. Call ``check_window()`` with ``baseline=True``. | |
6 | | 2 | Resize the logo using ``set_attribute()``. Call ``check_window()`` with ``level=0``. | The test detects that the logo has changed. The test does not fail because the check was set to ``level=0`` (print-only). A ``side_by_side_NAME.html`` file appears in the specific ``latest_logs/`` folder of the test. |
7 |
--------------------------------------------------------------------------------
/examples/visual_testing/python_home_test.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class VisualLayoutTests(BaseCase):
6 | def test_python_home_layout_change(self):
7 | self.open("https://python.org/")
8 | print('\nCreating baseline in "visual_baseline" folder.')
9 | self.check_window(name="python_home", baseline=True)
10 | # Remove the "Donate" button
11 | self.remove_element("a.donate-button")
12 | self.check_window(name="python_home", level=0)
13 |
--------------------------------------------------------------------------------
/examples/visual_testing/xkcd_visual_test.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | BaseCase.main(__name__, __file__)
3 |
4 |
5 | class VisualLayoutTests(BaseCase):
6 | def test_xkcd_layout_change(self):
7 | self.open("https://xkcd.com/554/")
8 | print('\nCreating baseline in "visual_baseline" folder.')
9 | self.check_window(name="xkcd_554", baseline=True)
10 | # Change height: (83 -> 130) , Change width: (185 -> 120)
11 | self.set_attribute('[alt="xkcd.com logo"]', "height", "130")
12 | self.set_attribute('[alt="xkcd.com logo"]', "width", "120")
13 | self.check_window(name="xkcd_554", level=0)
14 |
--------------------------------------------------------------------------------
/examples/xpath_test.py:
--------------------------------------------------------------------------------
1 | """Test that SeleniumBase can autodetect and use xpath selectors."""
2 | from seleniumbase import BaseCase
3 | BaseCase.main(__name__, __file__)
4 |
5 |
6 | class XPathTests(BaseCase):
7 | def test_xpath(self):
8 | self.open("https://seleniumbase.io/demo_page")
9 | self.assert_element('//h1[(text()="Demo Page")]')
10 | self.type('//*[@id="myTextInput"]', "XPath Test!")
11 | self.click('//button[starts-with(text(),"Click Me")]')
12 | self.assert_element('//button[contains(., "Purple")]')
13 | self.assert_text("SeleniumBase", "//table/tbody/tr[1]/td[2]/h2")
14 |
--------------------------------------------------------------------------------
/help_docs/using_safari_driver.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Using Safari's WebDriver for running browser tests on macOS
4 |
5 | *(NOTE: Safari's WebDriver requires macOS 10.13 "High Sierra" or later.)*
6 |
7 | You can find the official Apple documentation regarding "Testing with WebDriver in Safari" on the following page: [https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari](https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari)
8 |
9 | Run ``safaridriver --enable`` once in a terminal to enable Safari's WebDriver. (If you’re upgrading from a previous macOS release, you may need to prefix the command with ``sudo``.)
10 |
11 | Now you can use ``--safari`` to run your **SeleniumBase** tests on Safari.
12 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | pip install -e . --use-pep517 --config-settings="editable_mode=compat"
3 |
--------------------------------------------------------------------------------
/integrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/integrations/__init__.py
--------------------------------------------------------------------------------
/integrations/behave/behave.ini:
--------------------------------------------------------------------------------
1 | [behave]
2 | show_skipped=false
3 | show_timings=false
4 |
--------------------------------------------------------------------------------
/integrations/behave/features/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/integrations/behave/features/__init__.py
--------------------------------------------------------------------------------
/integrations/behave/features/behave.ini:
--------------------------------------------------------------------------------
1 | [behave]
2 | show_skipped=false
3 | show_timings=false
4 |
--------------------------------------------------------------------------------
/integrations/behave/features/environment.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 | from seleniumbase.behave import behave_sb
3 | behave_sb.set_base_class(BaseCase) # Accepts a BaseCase subclass
4 | from seleniumbase.behave.behave_sb import before_all # noqa
5 | from seleniumbase.behave.behave_sb import before_feature # noqa
6 | from seleniumbase.behave.behave_sb import before_scenario # noqa
7 | from seleniumbase.behave.behave_sb import before_step # noqa
8 | from seleniumbase.behave.behave_sb import after_step # noqa
9 | from seleniumbase.behave.behave_sb import after_scenario # noqa
10 | from seleniumbase.behave.behave_sb import after_feature # noqa
11 | from seleniumbase.behave.behave_sb import after_all # noqa
12 |
--------------------------------------------------------------------------------
/integrations/behave/features/fail_page.feature:
--------------------------------------------------------------------------------
1 | Feature: SeleniumBase scenarios for the Fail Page
2 |
3 | Scenario: Fail test on purpose to see what happens
4 | When Open the Fail Page
5 | Then Fail test on purpose
6 |
--------------------------------------------------------------------------------
/integrations/behave/features/realworld.feature:
--------------------------------------------------------------------------------
1 | Feature: SeleniumBase scenarios for the RealWorld App
2 |
3 | Scenario: Verify RealWorld App (log in / sign out)
4 | Given Open the RealWorld Login Page
5 | When Login to the RealWorld App
6 | Then Assert exact text "Welcome!" in "h1"
7 | When Highlight element "img#image1"
8 | And Click element 'a:contains("This Page")'
9 | Then Save a screenshot to the logs
10 | When Click link "Sign out"
11 | Then Assert element 'a:contains("Sign in")'
12 | And Assert text "You have been signed out!"
13 |
--------------------------------------------------------------------------------
/integrations/behave/features/steps/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/integrations/behave/features/steps/__init__.py
--------------------------------------------------------------------------------
/integrations/behave/features/steps/fail_page.py:
--------------------------------------------------------------------------------
1 | from behave import step
2 |
3 |
4 | @step("Open the Fail Page")
5 | def go_to_error_page(context):
6 | context.sb.open("https://seleniumbase.io/error_page/")
7 |
8 |
9 | @step("Fail test on purpose")
10 | def fail_on_purpose(context):
11 | context.sb.fail("This test fails on purpose!")
12 |
--------------------------------------------------------------------------------
/integrations/brython/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Getting Started with Brython
2 |
3 | * Brython was designed for replacing JavaScript with Python.
4 | * This tutorial will show you how to get started quickly.
5 |
6 | ### Here's the web app you'll be creating:
7 |
8 |
9 |
10 | ### 0. Install ``brython``:
11 |
12 | ```bash
13 | pip install brython
14 | ```
15 |
16 | ### 1. Get a web server up and running:
17 |
18 | Run from [SeleniumBase/integrations/brython](https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/brython) :
19 |
20 | ```bash
21 | python -m http.server
22 | ```
23 |
24 | (You can stop the server by using Ctrl+C )
25 |
26 | ### 2. Navigate to [http://localhost:8000/](http://localhost:8000/)
27 |
28 | Now click on the examples to see Brython in action.
29 |
30 | ### 3. For more info, see the following:
31 |
32 | * https://brython.info/
33 | * https://pypi.org/project/brython/
34 | * https://github.com/brython-dev/brython
35 |
--------------------------------------------------------------------------------
/integrations/brython/index.py:
--------------------------------------------------------------------------------
1 | from browser import document
2 |
3 |
4 | def setup_page():
5 | document["topHeader"].textContent = "Brython Examples:"
6 |
--------------------------------------------------------------------------------
/integrations/docker/docker-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 | echo "***** SeleniumBase Docker Machine *****"
4 | exec "$@"
5 |
--------------------------------------------------------------------------------
/integrations/docker/run_docker_test_in_chrome.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 | # Run example test from inside Docker image
4 | echo "Running example SeleniumBase test from Docker with headless Chrome..."
5 | cd /SeleniumBase/examples/ && pytest my_first_test.py --browser=chrome --headless
6 | exec "$@"
7 |
--------------------------------------------------------------------------------
/integrations/github/ReadMe.md:
--------------------------------------------------------------------------------
1 | ### GitHub Integrations
2 |
3 | > **Table of Contents / Navigation:**
4 | > - [**Actions/Workflows**](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/github/workflows/ReadMe.md)
5 | > - [**Extras/Action-Integrations**](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/github/workflows/extras.md)
6 |
--------------------------------------------------------------------------------
/integrations/linux/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Running SeleniumBase on Debian GNU/Linux
2 |
3 | Files in this folder are currently used with the [Jenkins on Microsoft Azure setup instructions for SeleniumBase](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/azure/jenkins/ReadMe.md), as well as with the [Jenkins on Google Cloud setup instructions for SeleniumBase](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/google_cloud/ReadMe.md). You can also use these files standalone with any Ubuntu/Debian GNU/Linux machine.
4 |
--------------------------------------------------------------------------------
/integrations/linux/Xvfb_launcher.sh:
--------------------------------------------------------------------------------
1 | # Activate Headless Display (Xvfb)
2 |
3 | sudo Xvfb -ac :99 -screen 0 1280x1024x16 > /dev/null 2>&1 &
4 | export DISPLAY=:99
5 | exec "$@"
6 |
--------------------------------------------------------------------------------
/integrations/linux/jenkins_permissions.sh:
--------------------------------------------------------------------------------
1 | # This file will add "jenkins" to the sudoers file.
2 |
3 | # To become jenkins from a different user, use the following:
4 | # sudo su jenkins
5 | # bash
6 |
7 | sudo sh -c "echo \"%jenkins ALL=(ALL:ALL) ALL\" >> /etc/sudoers"
8 | sudo sh -c "echo \"%jenkins ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
9 | sudo sh -c "echo \"jenkins ALL=NOPASSWD: ALL\" >> /etc/sudoers"
10 |
--------------------------------------------------------------------------------
/integrations/linux/tomcat_permissions.sh:
--------------------------------------------------------------------------------
1 | # This file will add "tomcat" to the sudoers file.
2 | # "tomcat" is the Jenkins user name by default on Bitnami Jenkins machines
3 |
4 | # To become tomcat from a different user, use the following:
5 | # sudo su tomcat
6 | # bash
7 |
8 | sudo sh -c "echo \"%tomcat ALL=(ALL:ALL) ALL\" >> /etc/sudoers"
9 | sudo sh -c "echo \"%tomcat ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
10 | sudo sh -c "echo \"tomcat ALL=NOPASSWD: ALL\" >> /etc/sudoers"
11 |
--------------------------------------------------------------------------------
/integrations/node_js/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/integrations/node_js/__init__.py
--------------------------------------------------------------------------------
/integrations/node_js/my_first_test.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import BaseCase
2 |
3 |
4 | class MyTestClass(BaseCase):
5 | def test_swag_labs(self):
6 | self.open("https://www.saucedemo.com")
7 | self.type("#user-name", "standard_user")
8 | self.type("#password", "secret_sauce\n")
9 | self.assert_element("#inventory_container")
10 | self.assert_text("Products", "span.title")
11 | self.click('button[name*="backpack"]')
12 | self.click("#shopping_cart_container a")
13 | self.assert_text("Your Cart", "span.title")
14 | self.assert_text("Backpack", "div.cart_item")
15 | self.click("button#checkout")
16 | self.type("#first-name", "SeleniumBase")
17 | self.type("#last-name", "Automation")
18 | self.type("#postal-code", "77123")
19 | self.click("input#continue")
20 | self.assert_text("Checkout: Overview")
21 | self.assert_text("Backpack", "div.cart_item")
22 | self.click("button#finish")
23 | self.assert_exact_text("Thank you for your order!", "h2")
24 | self.assert_element('img[alt="Pony Express"]')
25 | self.js_click("a#logout_sidebar_link")
26 |
--------------------------------------------------------------------------------
/integrations/node_js/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "app",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "start": "node ./bin/www"
7 | },
8 | "dependencies": {
9 | "express": "~4.21.0"
10 | }
11 | }
--------------------------------------------------------------------------------
/integrations/selenium_grid/ReadMe.md:
--------------------------------------------------------------------------------
1 | ### The ReadMe for the Selenium Grid Hub Launcher has been moved to: [seleniumbase/utilities/selenium_grid/ReadMe.md](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md) and all related code has been moved to [seleniumbase/utilities/selenium_grid](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid)
2 |
--------------------------------------------------------------------------------
/mkdocs_build/ReadMe.txt:
--------------------------------------------------------------------------------
1 | Help Docs Home Page:
2 |
3 | https://seleniumbase.io
4 |
--------------------------------------------------------------------------------
/mkdocs_build/docs_instructions.txt:
--------------------------------------------------------------------------------
1 | Preparing the SeleniumBase Docs website with "mkdocs"
2 |
3 | Usage: (from the top-level SeleniumBase folder)
4 | pip install -r mkdocs_build/requirements.txt
5 | mkdocs build (OR "mkdocs build --strict" to fail on warnings)
6 |
--------------------------------------------------------------------------------
/mkdocs_build/img/dash_pie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/dash_pie.png
--------------------------------------------------------------------------------
/mkdocs_build/img/dash_pie_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/dash_pie_2.png
--------------------------------------------------------------------------------
/mkdocs_build/img/dash_pie_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/dash_pie_3.png
--------------------------------------------------------------------------------
/mkdocs_build/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/favicon.ico
--------------------------------------------------------------------------------
/mkdocs_build/img/grad_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/grad_logo.png
--------------------------------------------------------------------------------
/mkdocs_build/img/green_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/green_icon.png
--------------------------------------------------------------------------------
/mkdocs_build/img/green_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/green_logo.png
--------------------------------------------------------------------------------
/mkdocs_build/img/green_logo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/green_logo2.png
--------------------------------------------------------------------------------
/mkdocs_build/img/green_logo3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/green_logo3.png
--------------------------------------------------------------------------------
/mkdocs_build/img/logo3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/logo3.png
--------------------------------------------------------------------------------
/mkdocs_build/img/logo3a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/logo3a.png
--------------------------------------------------------------------------------
/mkdocs_build/img/logo3b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/logo3b.png
--------------------------------------------------------------------------------
/mkdocs_build/img/logo3c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/logo3c.png
--------------------------------------------------------------------------------
/mkdocs_build/img/logo4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/logo4.png
--------------------------------------------------------------------------------
/mkdocs_build/img/logo5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/logo5.png
--------------------------------------------------------------------------------
/mkdocs_build/img/logo6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/logo6.png
--------------------------------------------------------------------------------
/mkdocs_build/img/logo7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/logo7.png
--------------------------------------------------------------------------------
/mkdocs_build/img/sb_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/sb_icon.png
--------------------------------------------------------------------------------
/mkdocs_build/img/sb_logo_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/sb_logo_10.png
--------------------------------------------------------------------------------
/mkdocs_build/img/sb_logo_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/sb_logo_7.png
--------------------------------------------------------------------------------
/mkdocs_build/img/side_by_side.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/mkdocs_build/img/side_by_side.png
--------------------------------------------------------------------------------
/mkdocs_build/img/social/share_facebook.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/mkdocs_build/img/social/share_gitter.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/mkdocs_build/img/social/share_instagram.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/mkdocs_build/img/social/share_twitter.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/mkdocs_build/index.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SeleniumBase
6 |
7 |
8 |
9 | Docs Home Page:
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/mkdocs_build/requirements.txt:
--------------------------------------------------------------------------------
1 | # mkdocs dependencies for generating the seleniumbase.io website
2 | # Minimum Python version: 3.9 (for generating docs only)
3 |
4 | regex>=2024.11.6
5 | pymdown-extensions>=10.15
6 | pipdeptree>=2.26.1
7 | python-dateutil>=2.8.2
8 | Markdown==3.8
9 | click==8.2.1
10 | ghp-import==2.1.0
11 | watchdog==6.0.0
12 | cairocffi==1.7.1
13 | pathspec==0.12.1
14 | Babel==2.17.0
15 | paginate==0.5.7
16 | mkdocs==1.6.1
17 | mkdocs-material==9.6.14
18 | mkdocs-exclude-search==0.6.6
19 | mkdocs-simple-hooks==0.1.5
20 | mkdocs-material-extensions==1.3.1
21 |
--------------------------------------------------------------------------------
/sbase/ReadMe.txt:
--------------------------------------------------------------------------------
1 | "SBase" is the short name of "SeleniumBase".
2 | Use with console scripts: "python -m sbase".
3 |
--------------------------------------------------------------------------------
/sbase/__init__.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import __version__ # noqa
2 | from seleniumbase import BaseCase # noqa
3 | from seleniumbase import decorators # noqa
4 | from seleniumbase import Driver # noqa
5 | from seleniumbase import DriverContext # noqa
6 | from seleniumbase import encryption # noqa
7 | from seleniumbase import get_driver # noqa
8 | from seleniumbase import js_utils # noqa
9 | from seleniumbase import shared_utils # noqa
10 | from seleniumbase import MasterQA # noqa
11 | from seleniumbase import page_actions # noqa
12 | from seleniumbase import page_utils # noqa
13 | from seleniumbase import SB # noqa
14 | from seleniumbase import translate # noqa
15 |
--------------------------------------------------------------------------------
/sbase/__main__.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 |
4 | # Remove "" and current working directory from the first entry
5 | # of sys.path (if present) to avoid using the current directory
6 | # in SeleniumBase commands when invoked as "python -m sbase "
7 | if sys.path[0] in ("", os.getcwd()):
8 | sys.path.pop(0)
9 |
10 | if __package__ == "":
11 | path = os.path.dirname(os.path.dirname(__file__))
12 | sys.path.insert(0, path)
13 |
14 | if __name__ == "__main__":
15 | import warnings
16 | from seleniumbase.console_scripts.run import main
17 |
18 | warnings.filterwarnings(
19 | "ignore", category=DeprecationWarning, module=".*packaging\\.version"
20 | )
21 | main()
22 | sys.exit()
23 |
--------------------------------------------------------------------------------
/seleniumbase/__main__.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 |
4 | # Remove "" and current working directory from the first entry
5 | # of sys.path (if present) to avoid using the current directory
6 | # in SeleniumBase commands when invoked as "python -m seleniumbase "
7 | if sys.path[0] in ("", os.getcwd()):
8 | sys.path.pop(0)
9 |
10 | if __package__ == "":
11 | path = os.path.dirname(os.path.dirname(__file__))
12 | sys.path.insert(0, path)
13 |
14 | if __name__ == "__main__":
15 | import warnings
16 | from seleniumbase.console_scripts.run import main
17 |
18 | warnings.filterwarnings(
19 | "ignore", category=DeprecationWarning, module=".*packaging\\.version"
20 | )
21 | main()
22 | sys.exit()
23 |
--------------------------------------------------------------------------------
/seleniumbase/__version__.py:
--------------------------------------------------------------------------------
1 | # seleniumbase package
2 | __version__ = "4.39.2"
3 |
--------------------------------------------------------------------------------
/seleniumbase/behave/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/behave/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/behave/steps.py:
--------------------------------------------------------------------------------
1 | from sbase import steps # noqa
2 | """
3 | This is a proxy for importing SeleniumBase-Behave steps.
4 | A short path name shortens the output of "behave" tests.
5 | See "../../sbase/steps.py" for the actual list of steps.
6 | Eg.
7 | BEHAVE STEP NAME # ../../sbase/steps.py:11 0.111s
8 | BEHAVE STEP NAME # ../../sbase/steps.py:74 0.550s
9 | BEHAVE STEP NAME # ../../sbase/steps.py:67 0.385s
10 | """
11 |
--------------------------------------------------------------------------------
/seleniumbase/common/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/common/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/common/unobfuscate.py:
--------------------------------------------------------------------------------
1 | """
2 | Unobfuscates an encrypted string/password into a plaintext string/password.
3 |
4 | Usage:
5 | python unobfuscate.py
6 | Then enter the encrypted string/password.
7 | The result is a plaintext string/password.
8 | Works the same as obfuscate.py, but doesn't mask the input.
9 | """
10 |
11 | from seleniumbase.common import encryption
12 | import time
13 |
14 |
15 | def main():
16 | input_method = input
17 | try:
18 | while 1:
19 | code = input_method(
20 | "\nEnter obfuscated/encrypted string: (CTRL+C to exit):\n"
21 | )
22 | print("\nHere is the unobfuscated string/password:")
23 | time.sleep(0.07)
24 | print(encryption.decrypt(code))
25 | time.sleep(0.21)
26 | except KeyboardInterrupt:
27 | print("\nExiting...\n")
28 |
29 |
30 | if __name__ == "__main__":
31 | main()
32 |
--------------------------------------------------------------------------------
/seleniumbase/config/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/config/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/config/proxy_list.py:
--------------------------------------------------------------------------------
1 | """
2 | Proxy Server "Phone Book".
3 |
4 | Simplify running browser tests through a proxy server
5 | by adding your frequently-used proxies here.
6 |
7 | Now you can do something like this on the command line:
8 | "pytest SOME_TEST.py --proxy=proxy1"
9 |
10 | Format of PROXY_LIST server entries:
11 | * "ip_address:port" OR "username:password@ip_address:port"
12 | * "server:port" OR "username:password@server:port"
13 | (Do NOT include the http:// or https:// in your proxy string!)
14 |
15 | Example proxies in PROXY_LIST below are not guaranteed to be active or secure.
16 | If you don't already have a proxy server to connect to,
17 | you can try finding one from one of following sites:
18 | * https://www.sslproxies.org/
19 | * https://bit.ly/36GtZa1
20 | * https://www.us-proxy.org/
21 | * https://hidemy.name/en/proxy-list/
22 | * http://free-proxy.cz/en/proxylist/country/all/https/ping/all
23 | """
24 |
25 | PROXY_LIST = {
26 | "example1": "98.8.195.160:443", # (Example) - set your own proxy here
27 | "example2": "200.174.198.86:8888", # (Example)
28 | "example3": "socks5://184.178.172.5:15303", # (Example)
29 | "proxy1": None,
30 | "proxy2": None,
31 | "proxy3": None,
32 | "proxy4": None,
33 | "proxy5": None,
34 | }
35 |
--------------------------------------------------------------------------------
/seleniumbase/console_scripts/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/console_scripts/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/core/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/core/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/core/application_manager.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 |
4 | class ApplicationManager:
5 | """Generating application strings for the Testcase Database."""
6 |
7 | @classmethod
8 | def generate_application_string(cls, test):
9 | """Generate a string based on some of the given information
10 | that's pulled from the test object: app_env, start_time."""
11 |
12 | app_env = "test"
13 | if hasattr(test, "env"):
14 | app_env = test.env
15 | elif hasattr(test, "environment"):
16 | app_env = test.environment
17 |
18 | start_time = int(time.time() * 1000)
19 |
20 | return "%s.%s" % (app_env, start_time)
21 |
--------------------------------------------------------------------------------
/seleniumbase/core/create_db_tables.sql:
--------------------------------------------------------------------------------
1 | # Creates test_db tables for using SeleniumBase with MySQL
2 |
3 | # test_run_data table
4 | # -----------------------------------
5 | CREATE TABLE `test_run_data` (
6 | `guid` varchar(64) NOT NULL DEFAULT '',
7 | `test_address` varchar(255) DEFAULT NULL,
8 | `env` varchar(64) DEFAULT NULL,
9 | `start_time` varchar(64) DEFAULT NULL,
10 | `execution_guid` varchar(64) DEFAULT NULL,
11 | `runtime` int(11),
12 | `state` varchar(64) DEFAULT NULL,
13 | `browser` varchar(64) DEFAULT NULL,
14 | `message` text,
15 | `stack_trace` text,
16 | `retry_count` int(11) DEFAULT '0',
17 | `exception_map_guid` varchar(64) DEFAULT NULL,
18 | `log_url` text,
19 | PRIMARY KEY (`guid`)
20 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
21 |
22 | # test_execution table
23 | # -----------------------------------
24 | CREATE TABLE `test_execution` (
25 | `guid` varchar(64) NOT NULL DEFAULT '',
26 | `total_execution_time` int(11),
27 | `username` varchar(255) DEFAULT NULL,
28 | `execution_start` bigint(20) DEFAULT '0',
29 | PRIMARY KEY (`guid`)
30 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31 |
--------------------------------------------------------------------------------
/seleniumbase/core/session_helper.py:
--------------------------------------------------------------------------------
1 | from seleniumbase import config as sb_config
2 |
3 |
4 | def end_reused_class_session_as_needed():
5 | if (
6 | hasattr(sb_config, "reuse_class_session")
7 | and sb_config.reuse_class_session
8 | and hasattr(sb_config, "shared_driver")
9 | and sb_config.shared_driver
10 | ):
11 | if (
12 | hasattr(sb_config.shared_driver, "service")
13 | and sb_config.shared_driver.service.process
14 | ):
15 | try:
16 | sb_config.shared_driver.quit()
17 | except Exception:
18 | sb_config.shared_driver = None
19 |
--------------------------------------------------------------------------------
/seleniumbase/drivers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/drivers/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/extensions/ReadMe.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | [ ](https://github.com/seleniumbase/SeleniumBase)
4 |
5 | SeleniumBase browser extension storage
6 |
7 | The List:
8 |
9 | * ad_block.zip => This extension blocks certain types of iframe ads from loading.
10 | * disable_csp.zip => This extension disables a website's Content-Security-Policy.
11 | * recorder.zip => Save browser actions to sessionStorage with good CSS selectors.
12 | * sbase_ext.zip => A Chromium extension that does nothing. (Used for testing purposes)
13 | * firefox_addon.xpi => A Firefox add-on that does nothing. (Used for testing purposes)
14 |
--------------------------------------------------------------------------------
/seleniumbase/extensions/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/extensions/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/extensions/ad_block.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/extensions/ad_block.zip
--------------------------------------------------------------------------------
/seleniumbase/extensions/disable_csp.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/extensions/disable_csp.zip
--------------------------------------------------------------------------------
/seleniumbase/extensions/firefox_addon.xpi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/extensions/firefox_addon.xpi
--------------------------------------------------------------------------------
/seleniumbase/extensions/recorder.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/extensions/recorder.zip
--------------------------------------------------------------------------------
/seleniumbase/extensions/sbase_ext.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/extensions/sbase_ext.zip
--------------------------------------------------------------------------------
/seleniumbase/fixtures/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/fixtures/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/fixtures/errors.py:
--------------------------------------------------------------------------------
1 | """SeleniumBase MySQL-related exceptions.
2 |
3 | This feature is DEPRECATED!
4 | Use self.skip() for skipping tests!
5 |
6 | Raising one of these in a test will cause the
7 | test-state to be logged appropriately in the DB
8 | for tests that use the SeleniumBase MySQL option."""
9 |
10 |
11 | class BlockedTest(Exception):
12 | """Raise this to mark a test as Blocked in the DB."""
13 | pass
14 |
15 |
16 | class SkipTest(Exception):
17 | """Raise this to mark a test as Skipped in the DB."""
18 | pass
19 |
20 |
21 | class DeprecatedTest(Exception):
22 | """Raise this to mark a test as Deprecated in the DB."""
23 | pass
24 |
--------------------------------------------------------------------------------
/seleniumbase/js_code/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/js_code/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/masterqa/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/masterqa/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/plugins/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/plugins/screen_shots.py:
--------------------------------------------------------------------------------
1 | """Screenshot Plugin for SeleniumBase tests that run with pynose / nosetests"""
2 | import os
3 | from nose.plugins import Plugin
4 | from seleniumbase.config import settings
5 |
6 |
7 | class ScreenShots(Plugin):
8 | """This plugin takes a screenshot when a test fails."""
9 | name = "screen_shots"
10 | logfile_name = settings.SCREENSHOT_NAME
11 |
12 | def options(self, parser, env):
13 | super().options(parser, env=env)
14 |
15 | def configure(self, options, conf):
16 | super().configure(options, conf)
17 | if not self.enabled:
18 | return
19 | self.options = options
20 |
21 | def add_screenshot(self, test, err, capt=None, tbinfo=None):
22 | test_logpath = self.options.log_path + "/" + test.id()
23 | if not os.path.exists(test_logpath):
24 | os.makedirs(test_logpath)
25 | screenshot_file = "%s/%s" % (test_logpath, self.logfile_name)
26 | test.driver.get_screenshot_as_file(screenshot_file)
27 |
28 | def addError(self, test, err, capt=None):
29 | self.add_screenshot(test, err, capt=capt)
30 |
31 | def addFailure(self, test, err, capt=None, tbinfo=None):
32 | self.add_screenshot(test, err, capt=capt, tbinfo=tbinfo)
33 |
--------------------------------------------------------------------------------
/seleniumbase/resources/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/resources/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/resources/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/resources/favicon.ico
--------------------------------------------------------------------------------
/seleniumbase/translate/__init__.py:
--------------------------------------------------------------------------------
1 | from seleniumbase.translate import chinese # noqa
2 | from seleniumbase.translate import dutch # noqa
3 | from seleniumbase.translate import french # noqa
4 | from seleniumbase.translate import italian # noqa
5 | from seleniumbase.translate import japanese # noqa
6 | from seleniumbase.translate import korean # noqa
7 | from seleniumbase.translate import portuguese # noqa
8 | from seleniumbase.translate import russian # noqa
9 | from seleniumbase.translate import spanish # noqa
10 |
--------------------------------------------------------------------------------
/seleniumbase/undetected/cdp_driver/__init__.py:
--------------------------------------------------------------------------------
1 | from seleniumbase.undetected.cdp_driver import cdp_util # noqa
2 | from seleniumbase.undetected.cdp_driver.cdp_util import start_async # noqa
3 | from seleniumbase.undetected.cdp_driver.cdp_util import start_sync # noqa
4 |
--------------------------------------------------------------------------------
/seleniumbase/utilities/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/utilities/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/utilities/selenium_grid/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/utilities/selenium_grid/__init__.py
--------------------------------------------------------------------------------
/seleniumbase/utilities/selenium_grid/font_color:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Text color variables
4 | txtund=$(tput sgr 0 1) # Underline
5 | txtbld=$(tput bold) # Bold
6 | regred=$(tput setaf 1) # Red
7 | regblu=$(tput setaf 4) # Blue
8 | reggrn=$(tput setaf 2) # Green
9 | regwht=$(tput setaf 7) # White
10 | txtrst=$(tput sgr0) # Reset
11 | info=${regwht}*${txtrst} # Feedback
12 | pass=${regblu}*${txtrst}
13 | warn=${regred}*${txtrst}
14 | ques=${regblu}?${txtrst}
15 |
16 | FAIL_MSG="${regred}[FAILURE]${txtrst}"
17 | SUCCESS_MSG="${reggrn}[SUCCESS]${txtrst}"
18 |
--------------------------------------------------------------------------------
/seleniumbase/utilities/selenium_grid/register-grid-node.bat:
--------------------------------------------------------------------------------
1 | java -jar selenium-server-standalone.jar -role node -hub http://127.0.0.1:4444/grid/register -browser browserName=chrome,maxInstances=5,version=latest,seleniumProtocol=WebDriver -browser browserName=firefox,maxInstances=5,version=latest,seleniumProtocol=WebDriver
--------------------------------------------------------------------------------
/seleniumbase/utilities/selenium_grid/register-grid-node.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | java -jar selenium-server-standalone.jar -role node -hub http://127.0.0.1:4444/grid/register -browser browserName=chrome,maxInstances=5,version=latest,seleniumProtocol=WebDriver -browser browserName=firefox,maxInstances=5,version=latest,seleniumProtocol=WebDriver
--------------------------------------------------------------------------------
/seleniumbase/utilities/selenium_grid/start-grid-hub.bat:
--------------------------------------------------------------------------------
1 | java -jar selenium-server-standalone.jar -role hub -timeout 230 -browserTimeout 170 -port 4444
--------------------------------------------------------------------------------
/seleniumbase/utilities/selenium_grid/start-grid-hub.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | java -jar selenium-server-standalone.jar -role hub -timeout 230 -browserTimeout 170 -port 4444
--------------------------------------------------------------------------------
/seleniumbase/utilities/selenium_ide/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seleniumbase/SeleniumBase/66740488c068f040c336d94b03f1a9615744e9d3/seleniumbase/utilities/selenium_ide/__init__.py
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [flake8]
2 | # W503 (line break before binary operator) can be ignored.
3 | exclude=recordings,temp
4 | ignore=W503
5 |
6 | [nosetests]
7 | # nocapture=1 (Display print statements from output)
8 | # (Undo this by using: "--nologcapture")
9 | # logging-level=INFO (Shorter logs than using DEBUG)
10 | nocapture=1
11 | logging-level=INFO
12 |
13 | [behave]
14 | show_skipped=false
15 | show_timings=false
16 |
--------------------------------------------------------------------------------
/win_install.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | pip install -e . --use-pep517 --config-settings="editable_mode=compat"
3 |
--------------------------------------------------------------------------------
/win_virtualenv.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | :: Performs necessary setup steps to allow the use of
3 | :: virtualenv commands such as "mkvirtualenv [ENV_NAME]"
4 | :: for creating and using Python virtual environments.
5 |
6 | py -m pip install --upgrade pip --user
7 | py -m pip install --upgrade wheel --user
8 | py -m pip install virtualenvwrapper-win --force-reinstall --user
9 | echo:
10 | echo:
11 | echo: *** You may now use virtualenv commands in your command shell. ***
12 | echo:
13 | echo: virtualenv commands:
14 | echo: * "mkvirtualenv [ENV_NAME]" - Create a Python virtual environment
15 | echo: * "deactivate" - Exit the current virtual environment
16 | echo: * "workon [ENV_NAME]" - Enter an existing virtual environment
17 | echo: * "lsvirtualenv" OR "workon" - List all virtual environments
18 | echo: * "rmvirtualenv [ENV_NAME]" - Delete a virtual environment
19 | echo:
20 | echo: Example:
21 | echo: mkvirtualenv seleniumbase
22 | echo: mkvirtualenv seleniumbase --python=[PATH_TO_PYTHON]
23 | echo:
24 |
--------------------------------------------------------------------------------