seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
5.34k stars 980 forks source link

Issue testing when URL opened redirects #1092

Closed grahamhar closed 2 years ago

grahamhar commented 2 years ago

Hi,

First thanks for your work on this library.

I have an issue which could just be of my own misunderstanding, or the setup of the Docker image I am using for testing with.

Docker images comes prebuilt with:

Google Chrome 94.0.4606.81 ChromeDriver 94.0.4606.61 (418b78f5838ed0b1c69bb4e51ea0252171854915-refs/branch-heads/4606@{#1204})

When the test below is run locally on MacOS in headless mode I get a passing test, when I execute this on the AWS Codebuild docker image it looks like the call to open URL is not following the redirect, I think this is proved by the fact the URI of the current browser is still the same as the one it was opened with but it should have redirected to the oauth login URI. Any help or pointers on how to address this would be appreciated.

def test_login(sb, setup_config):
    print(f'heading to {setup_config["landing_uri"]}')
    sb.open(setup_config['landing_uri'])
    url_before_login = sb.get_current_url()
    print(f'XXXXXX{sb.get_page_source()}XXXXX')
    print(landing_uri: {setup_config["landing_uri"]}')
    print(f'before login: {url_before_login}') # this should pring the redirected URI but it is still the same as landing_uri
    sign_in_form_username = sb.find_visible_elements('input#signInFormUsername')
    sign_in_form_username[0].send_keys(setup_config['username'])
    sign_in_form_password = sb.find_visible_elements('input#signInFormPassword')
    sign_in_form_password[0].send_keys(setup_config['password'])
    sign_in_form_button = sb.find_visible_elements('input#signInFormPassword')
    sign_in_form_button[0].submit()
    url_after_login = sb.get_current_url()
    assert url_before_login.startswith(f'https://{setup_config["prefix"]}-login.auth')
    assert url_after_login.startswith(f'https://{setup_config["prefix"]}-app')
grahamhar commented 2 years ago

realised there are discussions active so moved this over there https://github.com/seleniumbase/SeleniumBase/discussions/1094