antsakontsa
antsakontsa

Reputation: 307

Python: Selenium cannot find xpath of a page

I'm making a little app to make me a new repo for GitHub. It works well until it comes to the page where it should insert repository name, but in that page, it cannot find any elements XPath?

enter image description here

# Write new project name
newProject = driver.find_element_by_xpath(
    '//*[@id="repository_name"]')
newProject.send_keys('qwerty')

Upvotes: 0

Views: 64

Answers (1)

frianH
frianH

Reputation: 7563

This is correct locator: .find_element_by_xpath('//*[@id="repository_name"]')

May you need WebDriverWait like this:

By xpath

WebDriverWait(driver, 10).until(expected_conditions.visibility_of_element_located((By.XPATH, '//*[@id="repository_name"]')))
newProject = driver.find_element_by_xpath('//*[@id="repository_name"]')
newProject.send_keys('qwerty')

By id

WebDriverWait(driver, 10).until(expected_conditions.visibility_of_element_located((By.ID, 'repository_name')))
newProject = driver.find_element_by_id('repository_name')
newProject.send_keys('qwerty')

Following import:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions

Upvotes: 1

Related Questions