Home > OS >  Selenium can't get this class
Selenium can't get this class

Time:11-09

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/diventer image description here

CodePudding user response:

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']")
  • Related