1

I use selenium in python to read table data from a website. I want to get data1 and data2. I use the code like below. But I can only get the data2, the first code will print nothing. Can anyone tell me how to solve this problem? Thank you.

elem = browser.find_element_by_css_selector('td.el-table_1_column_1.is-hidden div')
print(elem.text)
elem = browser.find_element_by_css_selector('td.el-table_1_column_2 div')
print(elem.text)
<td class="el-table_1_column_1   is-hidden">
    <div class="cell">data1</div>
</td>
<td class="el-table_1_column_2  ">
    <div class="cell">data2</div>
</td>

1 Answer 1

1

Use elem.get_attribute("textContent") to get the hidden value from node.

elem = browser.find_element_by_css_selector('td.el-table_1_column_1.is-hidden div')
print(elem.get_attribute("textContent"))

Please check the following Link

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

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.