In the google chrome inspector console enter the xpath:


the console returns the element, therefore the xpath is correct.

But then in the python console I have the result that it does not find the element, the script is:

import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
driver = webdriver.Chrome()
parentHandle = driver.current_window_handle
print("Handle principal: " , parentHandle)
download = driver.find_element(By.XPATH, 
if download is not None:
wait = WebDriverWait(driver, 10)
pass = espera.until(EC.element_to_be_clickable((By.XPATH, 
if pass is not None:

I use Python, Selenium Web Driver and Chrome Browser

thanks who can have any ideas

1 Answer 1


Your xpath locator is wrong , try the below xpath:

/html/body/div/div/footer/md-toolbar/div/div[2]/img[2]/../../../../../../../../body[@class="layout-column md-dialog-is-showing"]

The errors were ,

  1. space after /html/body/div/div/footer/md-
  2. more than one space character after body[@class="layout-column
  3. You navigated back to parent only seven times, ../../../../../../.. which brings you back to body element. From here you are again trying to get 'body' which will look for body inside body. But there won't be any such element. You have to navigate back one more time and then search for the body element


I am not sure why you use such a locator when you can easily get the element by just using the locator

//body[@class="layout-column md-dialog-is-showing"]

I hope you are trying to learn xpath and not going to push such a code


Try to develop best practices like using CSS, IDs , using relative XPaths, using less complex locators etc from initial learning phase only

Else , you will pickup all the bad practices and will implement in professional life also.

  • 1
    Thank you very much, very complete your answer : ) Commented Jan 10, 2020 at 17:12
  • I would not suggest to use class when unique ID property is available. Commented Jan 14, 2020 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.