1

Please I'm quite a selenium newbie and I really need help to get the data for my thesis. I scrapping the marketplace from this url https://www.tokopedia.com/sunxin

I want to get the data from the button called "Info Toko", if user click this will shown a pop up content enter image description here enter image description here

The original source code for this button is:

<button class="css-rhf1fq-unf-btn e1ggruw00"><span>Info Toko</span></button>

I've tried to get the element by xpath, classname, link text but still not working.

driver.find_element_by_link_text('Info Toko')

Always get error message like this enter image description here

A very big thank you for anyone who can give a suggest or advice to get this element

2

Try by using xpath selector

In which you want to change your selector code as shown below

driver.find_element_by_xpath('//div[@class="css-ais6tt"]//button[3]')

This will work

| improve this answer | |
0

When ever you use a method read its documentation :

https://selenium-python.readthedocs.io/locating-elements.html

continue_link = driver.find_element_by_link_text('Continue')
continue_link = driver.find_element_by_partial_link_text('Conti')

This two element locators identifies the element only using link text.

In selenium a link is "an anchor tag" , an anchor tag is used wrap a href link

in your case its a button tag and not a anchor 'a' tag, so link text method won't work

use xpath , css or class

xpath:

driver.find_element_by_xpath('//button[text()="Info Toko"]')

css:

css to find using class

driver.find_element_by_css_selector('button.css-rhf1fq-unf-btn.e1ggruw00')

class:

driver.find_element_by_class_name('css-rhf1fq-unf-btn e1ggruw00')
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.