1

I have crawled information from website and wants to print out the content but the printed is something like "selenium drive 0xxxxxx"

<selenium.webdriver.remote.webelement.WebElement (session="97c10cfffe2d37a0b68b670218a2244a", element="8a3b18d3-a004-4349-8af1-1aaac3e430de")>, 
<selenium.webdriver.remote.webelement.WebElement (session="97c10cfffe2d37a0b68b670218a2244a", element="3784ddd4-48db-451b-a0ff-ae40ef92cd07")>,

Code trials:

day1 = s.find_element(By.XPATH, '//*[@id="exp-0-header"]/tr[2]/td[1]/span')
day2 = s.find_element(By.XPATH, '//*[@id="exp-1-header"]/tr[2]/td[1]/span')
day3 = s.find_element(By.XPATH, '//*[@id="exp-2-header"]/tr[2]/td[1]/span')
day_rows1 = s.find_element(By.XPATH, '//*[@id="exp-0-div"]/div[1]/span[2]/b[1]')
day_rows2 = s.find_element(By.XPATH, '//*[@id="exp-1-div"]/div[1]/span[2]/b[1]')
day_rows3 = s.find_element(By.XPATH, '//*[@id="exp-2-div"]/div[1]/span[2]/b[1]')
   
elements = []
elements = s.find_elements(By.CLASS_NAME, 'strike-row')
print(elements)

And above is the code, how would I solve this obstacles? I am new to python siders and I couldn't find relevant info on stack overflow Appreciate any suggestions thank you!

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Hans Han
  • 23
  • 2

1 Answers1

0

You were close enough. Your code is identifying the desired elements and creating a list. As you are printing the WebElement list, you see the output as:

<selenium.webdriver.remote.webelement.WebElement (session="97c10cfffe2d37a0b68b670218a2244a", element="8a3b18d3-a004-4349-8af1-1aaac3e430de")>, 
<selenium.webdriver.remote.webelement.WebElement (session="97c10cfffe2d37a0b68b670218a2244a", element="3784ddd4-48db-451b-a0ff-ae40ef92cd07")>,

Your test aim should be to extract the elements' text. As an example to print the text/innerText you can use list comprehension as follows:

print([my_elem.text for my_elem in driver.find_elements(By.CLASS_NAME, "strike-row")])
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352