简体   繁体   中英

no such element: Unable to locate element: {“method”:“css selector”,“selector”:“[id=”guided-tour-tag-credentials-new“]”}

I want to use selenium to create credentials here , but it shows error :

what "iframe xpath here" should I replace here? here is my code content:

driver = webdriver.Edge()

wait = WebDriverWait(driver, 10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "iframe xpath here")))

driver.get("https://ms.web.purview.azure.com/resource/prod0719/main/catalog/management/accountInformation?feature.tenant=72f988bf-86f1-41af-91ab-2d7cd011db47")

driver.set_window_size(1200, 900)
sleep(15)
driver.find_element_by_id("managementCredentials").click()
sleep(5)

Message:

 no such element: Unable to locate element: {"method":"css selector","selector":"[id="guided-tour-tag-credentials-new"]"} (Session info: MicrosoftEdge=91.0.864.70)

here is my code content now after switching to iframe: 在此处输入图片说明

iframe content:

screenshot2: 在此处输入图片说明

screenshot3: 在此处输入图片说明

Looks like it's an iframe, if it is, you need to switch first before interaction :

Code :

wait = WebDriverWait(driver, 10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "iframe xpath here")))

and then you can interact :

driver.find_element_by_id("guided-tour-tag-credentials-new").click()

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

once done, switch to default content like this :

driver.switch_to.default_content()
  1. Possibly you have to add wait before accessing that element to let him loaded.
  2. Possibly it is inside an iframe.
  3. Possibly the id attribute is dynamically changing on the page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM