我正在嘗試單擊按鈕,但 Selenium 無法訪問該類:
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)
此 xpath 無效:
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: 無法對“檔案”執行“評估”:字串 '//div[@class='/html/body/div/div/div
uj5u.com熱心網友回復:
我不知道是什么self._get_xpath
,但通常這樣的事情可能應該有效:
key_cli_btn = driver.find_element(By.XPATH, "//div[@class='access-grants__flows-area__create-button container']")
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/531102.html