Last active
March 14, 2025 05:23
-
-
Save premchalmeti/580f38fc9fed7b94d7b39ab63d90eaf6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
import constants | |
import elements | |
def get_driver(): | |
return webdriver.Chrome() | |
def take_screenshot(driver, css_selector, filename): | |
element = driver.find_element(by=By.CSS_SELECTOR, value=css_selector) | |
element.screenshot(filename) | |
# driver.executeScript("arguments[0].scrollIntoView();", element) | |
# File screenshot = ele.getScreenshotAs(OutputType.FILE) | |
def accept_if_cookies(driver): | |
accept_btn = driver.find_element(by=By.CSS_SELECTOR, value=elements.COOKIES_ACCEPT) | |
accept_btn.click() | |
def goto_contact_us(): | |
driver = get_driver() | |
driver.get(constants.CONTACT_US) | |
# https://www.selenium.dev/documentation/webdriver/elements/locators/ | |
# accept_if_cookies(driver) | |
take_screenshot( | |
driver, | |
css_selector=elements.CONTACT_US_FORM, | |
filename='contact_us_form.png' | |
) | |
driver.quit() | |
if __name__ == '__main__': | |
goto_contact_us() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment