Software Quality Assurance & Testing Asked by Nizariansyah Agung on November 19, 2021
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
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
A very big thank you for anyone who can give a suggest or advice to get this element
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')
Answered by PDHide on November 19, 2021
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
Answered by Mohamed Sulaimaan Sheriff on November 19, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP