Last active
January 19, 2023 13:10
-
-
Save FernandoCelmer/3ea067d5c8753302b1b52c37f1c44ce3 to your computer and use it in GitHub Desktop.
bitbucket_selenium.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
selenium==4.6.0 | |
webdriver-manager==3.8.4 | |
packaging==21.3 | |
beautifulsoup4==4.11.1 | |
""" | |
from time import sleep | |
from bs4 import BeautifulSoup | |
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
from webdriver_manager.chrome import ChromeDriverManager | |
def get_chrome_browser(headless: bool = False): | |
chrome_options = webdriver.ChromeOptions() | |
chrome_options.add_argument("--no-sandbox") | |
chrome_options.add_argument("--disable-dev-shm-usage") | |
if headless: | |
chrome_options.add_argument("--headless") | |
executable_path = ChromeDriverManager().install() | |
return webdriver.Chrome( | |
executable_path=executable_path, | |
chrome_options=chrome_options | |
) | |
if __name__ == "__main__": | |
driver = get_chrome_browser() | |
url = input("URL: ") | |
input_email = input("E-mail: ") | |
input_password = input("Password: ") | |
input_environment = input("Environment: ") | |
driver.get(url) | |
username = driver.find_element(By.NAME, "username") | |
username.send_keys(input_email) | |
username.submit() | |
sleep(1) | |
password = driver.find_element(By.NAME, "password") | |
password.send_keys(input_password) | |
password.submit() | |
driver.find_elements(By.ID, "root") | |
page_source = BeautifulSoup(driver.page_source, "html.parser") | |
sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment