Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

parse error while trying to fetch web elements

Error Message

the string is not a valid xpath expression

HTML

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<div class="w-100 di-m flex-auto">
    <div class="ma3 ma4-m mt1-m">
        <section>
            <div class="mv4">
                <div class="w_0Uhy w_tfcE">
                </div>
            </div>
            <div class="mv4">
                <div class="w_0Uhy w_tfcE">
                </div>
            </div>
            <div class="mv4">
                <div class="w_0Uhy w_tfcE">
                </div>
            </div>
            <div class="mv4">
                <div class="w_0Uhy w_tfcE">
                </div>
            </div>
        </section>
    </div>
</div>

Selenium Python Code

webd = webdriver.Chrome(service=s, options=options)
webd.get("url")
webd.find_element(By.XPATH, "//div[@class='w-100']//div[@class='ma3']//section//div[@class='mv4']")

Is it the correct way to fetch

>Solution :

You can try something like contains() method:

webd.find_element(By.XPATH, "//*[contains(@class,'w-100')]/div/section/div[@class='mv4']")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading