-
Notifications
You must be signed in to change notification settings - Fork 12
/
run_selenium.py
34 lines (27 loc) · 995 Bytes
/
run_selenium.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
# Filename: run_selenium.py
"""
import time
import os.path
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
## Setup chrome options
chrome_options = Options()
chrome_options.add_argument("--headless") # Ensure GUI is off
chrome_options.add_argument("--no-sandbox")
# Set path to chromedriver as per your configuration
homedir = os.path.expanduser("~")
chrome_options.binary_location = f"{homedir}/chrome-linux64/chrome"
webdriver_service = Service(f"{homedir}/chromedriver-linux64/chromedriver")
# Choose Chrome Browser
browser = webdriver.Chrome(service=webdriver_service, options=chrome_options)
# Get page
browser.get("https://cloudbytes.dev")
# Extract description from page and print
description = browser.find_element(By.NAME, "description").get_attribute("content")
print(f"{description}")
# Wait for 10 seconds
time.sleep(10)
browser.quit()