0

I want to create a bot to automatically create instagram accounts using selenium and python for learning purposes. I have run into the problem that I cant get the text of the element that was created by the random string generator random.org.

I have already tried to get the txt of the element by using elem.text() and by get_attribute("value").

browser.get("https://www.random.org/passwords/")
start = browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/p[5]/input[1]")
start.click()
time.sleep(2)
string5 = browser.find_element_by_xpath("/html[1]/body[1]/div[1]/ul[2]/li[5]")
string4 = browser.find_element_by_xpath("/html[1]/body[1]/div[1]/ul[2]/li[4]")



The html of the object is

<li>YWKLGQ2V</li>

And the xpath is

/html[1]/body[1]/div[1]/ul[2]/li[4]

When I try string4.txt() I get

str is not callable

When I try get_attribute("value") I get

0

Nathaniel
  • 3,230
  • 11
  • 18
python_beginner
  • 105
  • 2
  • 4
  • 12

1 Answers1

1

Try calling string4.text. This variable is an element, not a string, but it may have a text value stored within it that you can access.

Nathaniel
  • 3,230
  • 11
  • 18