0

I want to capture the web element highlighted in the below screenshot:

inspect element for'Deployments'

I have already tried following options (using absolute as well as relative path):

  1. submit = driver.find_element_by_xpath("html/body/vra-root/vra-shell/clr-main-container/vra-tabs/nav/ul/li[2]/a").click()
  2. submit = driver.find_element_by_xpath("//ul[@class='nav']//li[@class='nav-item ng-star-inserted']//a[@id='csp.cs.ui.deployment'] and contains [text()='Deployments']").click()
  3. submit = driver.find_element_by_xpath("//a[text()='Deployments']").click()
  4. content = driver.find_element_by_css_selector('a.nav-link').click()

But, everytime I am getting the follwing error message`NoSuchElementException: Message: no such element: Unable to locate element:

I am new to this, any help is appreciated!`

2 Answers2

0

This looks like in an iframe, if yes then you can switch it to iframe first like this :

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

and then click :

driver.find_element_by_xpath("//a[text()='Deployments']").click()
cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • where do you see `iframe` in that screenshot? I guess it's possible that it exists, but we need to see more of the HTML to know for sure – JD2775 May 28 '21 at 19:09
  • `This looks like in an iframe` read this. OP has tried almost all way to click on it and got NoSuchEement exception so it could be in iframe. but that is my guess, waiting for OP to share his feedback and then can give proper solution – cruisepandey May 28 '21 at 19:11
  • 1
    Thanks @cruisepandey. It was an iframe issue. It resolved now. – chandersheel May 29 '21 at 10:08
0

If it's not an iframe issue as @cruisepandy described then try adding a wait around it to see if that helps

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


wait = WebDriverWait(driver, 10)

submit = wait.until(EC.element_to_be_clickable((By.XPATH, "//a[text()='Deployments']")))
submit.click()
JD2775
  • 3,658
  • 7
  • 30
  • 52