How to get the updated url from firefox browser using selenium and Python? The below code is a very good working example of what I am trying to do. The script opens up a url, looks for the search bar in the webpage, pastes a particular product and then executes the search.
I am trying to extract the updated url after the search is completed which should be https://www.myntra.com/avene-unisex-thermal-spring-water-50-ml but I am getting https://www.myntra.com/. How can I get the required url?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
firefoxOptions = webdriver.FirefoxOptions()
firefoxOptions.set_preference("dom.webnotifications.enabled", False)
driver = webdriver.Firefox(firefox_options = firefoxOptions)
driver.implicitly_wait(5)
# Maximize the browser window
driver.maximize_window()
# navigate to the home page
driver.get("https://www.myntra.com/")
# Locate the text field to update values
text_field = driver.find_element_by_class_name("desktop-searchBar")
# Clears any value already present in text field
text_field.clear()
# Updates the string in search bar
text_field.send_keys("Avene Unisex Thermal Spring Water 50 ml")
text_field.send_keys(Keys.ENTER)
new_page = driver.current_url
print(new_page)
driver.close()