F
F
First Second2020-11-01 11:36:06
Python
First Second, 2020-11-01 11:36:06

Selenium, Python | get_attribute('text') method returns None?

Hi all. Faced the following problem. The get_attribute('text') method, which should return the element's text value, returns None. Here is the code:

def test_buy():
        self.driver.get('https://receive-sms.com/')
        elem = WebDriverWait(self.driver, 10).until(
             EC.visibility_of_element_located((By.XPATH, '//*[@id="messages-table"]/tbody/tr[1]/td[4]')))
        return elem.get_attribute('text')


This site has a few items that I need:
<td data-title="[Date]" class="td-date" title="2020-11-01 06:26:18">[2020-11-01 06:26:18]</td>
<td data-title="[From]" class="td-from">[17192126163]</td>
<a title="Click to see SMS received on 12048193380" href="/12048193380" style="color:white;">12048193380</a>
<td data-title="[Message]" class="td-message">[101955 is your verification code for your Sony account.]</td>


When trying to get text from 1,2 and 4th elements, None arrives. From the 3rd element I get the text, all the rules. What could be the problem? Something in square brackets...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2020-11-01
@vmolostvov

Python useselem.text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question