how do i get current page url with python selenium?

Viewed 33

I want to know from which page the api request has come.

so I tried,

@test_bp.route("/test2")
def test2():
    options = webdriver.ChromeOptions() 
    options.add_experimental_option("excludeSwitches", ["enable-logging"])
    driver = webdriver.Chrome(executable_path="D:\pathto/chromedriver.exe", options=options)

    path = driver.current_url    
    print(path)

    return ""

and got this for print(path)

data:,

I do get proper url if I put driver.get(URL) before getting path = driver.current_url. However, I can't put the url which I don't know at the moment dealing with the api request.

Would there be any other way? Or should I just giveup and ask additional page information from the client side?

0 Answers
Related