1

I can select the first class="hm-Login_InputField "> fine and pass in user name

<div class="hm-Login ">
    <div class="hm-Login_UserNameWrapper ">
        <input type="text" class="hm-Login_InputField ">
        <div class="hm-Login_InputText ">Join</div>
    </div>
    <div class="hm-Login_PasswordWrapper ">
        <input type="text" class="hm-Login_InputField ">
        <input type="password" class="hm-Login_InputField Hidden ">
        <button tabindex="0" class="hm-Login_LoginBtn ">GO</button>
        <div class="hm-Login_InputText ">Lost Login?</div>
    </div>
</div>

elem = driver.find_element_by_class_name("hm-Login_InputField")
elem.click()
elem.send_keys("xxxxx")

I've tired copying the Xpath for the 2nd text input / password textbox. with inconstant results, sometimes it works, sometimes it doesn't.

/html/body/div[1]/div/div[1]/div/div[1]/div[2]/div/div[2]/input[2]

How can I select the 2nd class="hm-Login_InputField? text input / password textbox?

Do I need a relative Xpath? How is this derived?

I've tried:

elem = driver.find_element_by_class_name("hm-Login_InputField Hidden ")
elem.click()
elem.send_keys("xxxxx")

NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":".hm-Login_InputField Hidden "} (Session info: chrome=77.0.3865.120)

0

3 Answers 3

1

This xpath was successful:

Elem = driver.find_element_by_xpath(**"//div[@class='hm-Login_PasswordWrapper ']//input[@type='text']")** 
elem.click() 
elem.clear() 

I'm now able to select the box.

Thanks @Shubham Jain

Sign up to request clarification or add additional context in comments.

Comments

0

Check if any frame is present if yes then you need to switch to frame first.

Also add wait first like explict wait like visibilityOfElementLocated or presenceOfElementLocated

try below xpath as well:

//input[@type='password']

OR

//div[@class='hm-Login ']//div[@class='hm-Login_PasswordWrapper ']//input[@type='password']

2 Comments

elem = driver.find_element_by_xpath("//div[@class='hm-Login_PasswordWrapper ']//input[@type='text']") elem.click() elem.clear() im now able to select the box , however now I can't .sendkeys(). and im getting ElementNotInteractableException: element not interactable I've tried adding in a WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='hm-Login_PasswordWrapper ']//input[@type='text']"))).click() and. driver.implicitly_wait(10) # seconds both unsuccessful... this is one the www.bet365.com.au website..if you want to try.
Kindly accept the answer if your issue ask in question resolve... for new issue kindly create an another question.. thats how stack works and its policy stated
0

If it works sometimes that may be because of an element loading slower. Try to add time.sleep(2) before you call the second element and see if it works. Also instead of driver.find_element_by_class_name("hm-Login_InputField Hidden ") you can use driver.find_elements_by_class_name("hm-Login_InputField") and this will return all the elements with class "hm-Login_InputField". Then elem[0] will be your first input elem[1] the second and goes on and on.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.