I am writing a Python
script for interacting with the Spotify Webplayer
.
Initially I have to login by entering the credentials. After I click the login button and I get redirected to the webplayer page. But now if I try to interact with the elements on this page, Python
throws an error that the following element is not present.
from selenium import webdriver
driver=webdriver.Chrome(r'C:\Users\admin\Downloads\chromedriver_win32\chromedriver.exe')
driver.get("https://open.spotify.com/collection/playlists")
a = driver.find_element_by_xpath('//button[contains(text(),"Log in")]')
a.click()
driver.find_element_by_id("login-username").send_keys("email")
driver.find_element_by_id("login-password").send_keys("psswd")
ERROR: Message: no such element: Unable to locate element: {"method":"id","selector":"login-username"}
I know that the browser still holds the old page instance, hence it cannot find the required elements. How can I overcome this issue?