Created
June 29, 2022 17:31
-
-
Save SarahElson/02d6c0344eca8639fa9b0b57c6a0e6dc to your computer and use it in GitHub Desktop.
How To Get Current URL In Selenium Python
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.webdriver.common.by import By | |
from selenium.webdriver.common.keys import Keys | |
class EcommercePlaygroundPage: | |
#url | |
url = 'https://ecommerce-playground.lambdatest.io/' | |
#locators | |
search_form = (By.NAME, "search") | |
search_button = (By.CSS_SELECTOR, ".type-text") | |
# Initializer | |
def __init__(self, browser): | |
self.browser = browser | |
# Interaction methods | |
def load(self): | |
self.browser.get(self.url) | |
self.browser.implicitly_wait(30) | |
def search(self , keyword): | |
search_form = self.browser.find_element(*self.search_form) | |
search_form.send_keys(keyword) | |
search_button = self.browser.find_element(*self.search_button) | |
search_button.click() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment