Home > Enterprise >  not able to find the element
not able to find the element

Time:06-24

Hi I would like to find the element on the web page and further provide the string in to the text box. Inspected web page looks like below.

<div>
    <label  for="login">User ID</label>
    <input type="text" name="login" id="login"  placeholder="User ID">
</div>

I have tried all below options but nothing got worked, would be really great if you could provide the solution

from selenium.webdriver.common.by import By
driver.find_element(By.XPATH, "//input[@id='login']") 
driver.find_element(By.XPATH, "//input[@name='login']") 
driver.find_element(By.XPATH, "//input[@class='inforTextbox']") 
driver.find_element(By.XPATH, "//input[@id='login']") 
driver.find_element(By.ID, "login")

and getting one of the below error

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@id='login']"}

CodePudding user response:

Can you try below xpath

//input[@placeholder = 'User ID']

CodePudding user response:

The web page has the frames so earlier it was not accessing the elements. I selected first frame like below. Then able to select the further elements. Thank you all

driver.switch_to_frame('topframe')
  • Related