Created
June 29, 2022 17:33
-
-
Save SarahElson/9ff8a9e0dc6051ad53390d74e5ecd411 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
import pytest | |
from pages.ecommerce_playground import EcommercePlaygroundPage | |
keyword = "iPhone" | |
def test_ecommerce_playground(browser): | |
ecommerce_page = EcommercePlaygroundPage(browser) | |
ecommerce_page.load() | |
ecommerce_page.search(keyword) | |
get_url = browser.current_url | |
title = browser.title | |
print("The current url is: "+str(get_url)) | |
assert "iPhone" in get_url | |
with open('urls.txt', 'a') as f: | |
f.write(title + " : "+ get_url) | |
f.write('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment