Find <span class

I need to fetch the product name from this link with selenium in python. I’ve tried everything and still can’t.
Help me please.


Hey @Paulo,

Here is an example for this particular case.
Using xpath along with contains solves the problem.

Here is the code example:

from botcity.web import WebBot

class Bot(WebBot):
    def action(self, execution=None):
        # Configure whether or not to run on headless mode
        self.headless = False

        # Uncomment to change the default Browser to Firefox
        # self.browser = Browser.FIREFOX

        # Opens the BotCity website.

        # Use xpath along with the contains function to search for the element which class attribute
        # contains "product-title"
        ele = self.driver.find_element_by_xpath("//span[contains(@class, 'product-title')]")

        # Get the element text

        # Wait for 2 seconds before closing

        # Stop the browser and clean up

if __name__ == '__main__':

If you run this code you will get the following output:

Smartphone Motorola Moto G30 128GB 4G Wi-Fi Tela 6.5’’ Dual Chip 4GB RAM Câmera Quádrupla + Selfie 13MP - Dark Prism

More info here: How to use regular expressions in xpath in Selenium with python?

Let me know if it works for you.