I am trying to click on the anchor tag on instagram's page which says log in. Here is my code.
browser = webdriver.Chrome()
browser.get('https://instagram.com')
login_elem = browser.findElement(By.xpath('//p/a[text() = "Log in"'))
login_elem.click()
The browser opens however the element is not clicked. I have tried various other xpaths and none worked. Here is the image for the Instagram source.
This is what i tried on my local system and it worked
from selenium.webdriver.common.by import By
from selenium import webdriver
driver = webdriver.Chrome(executable_path="D:\\cs\\chromedriver.exe")
driver.get("https://www.instagram.com/")
a=driver.find_element(By.XPATH,'//a[text() = "Log in"]')
# added this step for compatibility of scrolling to the view
driver.execute_script("return arguments[0].scrollIntoView();", a)
a.click()
Corrected the XPATH and other changes.Please note executable path should be replaced with your path.