Python Forum
Multiple input box in a webpage have same XPATH
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple input box in a webpage have same XPATH
#3
(Jul-18-2018, 01:29 PM)buran Wrote: it looks like driver.find_elements_by_xpath('(//*[@id="d_value"])') returns list. Check how many elements it has. In any case, even if it is one element list, you need to get the desired element.

It seems there are two elements in the list, I printed the list using the below code-
ser = driver.find_elements_by_xpath('(//*[@id="d_value"])')
print(ser)
and got the output like below -
Output:
[<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="4c136be8-69d7-4a62-9c94-8659e3ab2190", element="425ebdba-c5c5-4a58-a31f-dfc44c753c6d")>, <selenium.webdriver.firefox.webelement.FirefoxWebElement (session="4c136be8-69d7-4a62-9c94-8659e3ab2190", element="fc40d0ff-34c6-4c81-8114-bd66e0e2e98d")>]
There are two input boxes in the webpage which I already mentioned, and here two list elements are printed. So it exactly matches with the number of input boxes.

But when I am doing this to select the input box-
ser = driver.find_elements_by_xpath('(//*[@id="d_value"])[1]').click()
I am getting error like below -
Error:
ser = driver.find_elements_by_xpath('(//*[@id="d_value"])[1]').click() AttributeError: 'list' object has no attribute 'click'
It means click is not applicable here in a list type object. Then how to solve the issue or how to click on a list type object and send keystrokes using send_keys().
Reply


Messages In This Thread
RE: Multiple input box in a webpage have same XPATH - by sumandas89 - Jul-19-2018, 08:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  need help with xpath pythonprogrammer 1 2,776 Jan-18-2020, 11:28 PM
Last Post: snippsat
  webpage input module rudolphyaber 2 2,211 Feb-26-2019, 12:13 AM
Last Post: Larz60+
  display multiple sensors on webpage python flask jinja pascale 6 5,324 Jan-29-2019, 10:10 AM
Last Post: pascale
  Scrape Multiple items from a webpage Prince_Bhatia 2 3,344 Sep-12-2017, 06:08 AM
Last Post: Prince_Bhatia

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020