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

Selenium can't get this class

I’m trying to get the button clicked but Selenium cant reach that class :

access-grants__flows-area__create-button container

key_cli_btn = self._get_xpath("//div[@class='/html/body/div/div/div[1]/div/div[3]/div/div[2]/div[2]/div[3]/div[4]/div'")
    print(key_cli_btn)

This xpath is invalid :

    selenium.common.exceptions.InvalidSelectorException: Message: invalid selector:    `Unable to locate an element with the xpath expression //div[@class='/html/body/div/div/div[1]/div/div[3]/div/div[2]/div[2]/div[3]/div[4]/div' because of the following error:

`SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//div[@class=’/html/body/div/div/div[1]/div/div[3]/div/div[2]/div[2]/div[3]/div[4]/div” is not a valid XPath expression.

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

or I’ve tried to start from this div class:

dashboard__wrap__main-area__content-wrap

but I don’t know how to get "child"

[![enter image description here][1]][1]

Edit1:

    def _get_xpath(self, xpath: str) -> webdriver:
    return self.driver.find_element(By.XPATH, xpath)

>Solution :

I have no idea what self._get_xpath is, but generally something like this probably should work:

key_cli_btn = driver.find_element(By.XPATH, "//div[@class='access-grants__flows-area__create-button container']")
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