unable to click on a div with selenium (ng-click) Python










0















Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry



What I want to try is to automate the access to a web that I leave and link here
RUNT



The first part I have solved that is to enter the data to the form and resolve the im not to robot in send



I'm going to post all the code in python



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

import pandas as pd
import threading
import time
import csv
import os


# options = webdriver.ChromeOptions()
# options.add_argument(
# r'user-data-dir=C:UsersRADEONAppDataLocalGoogleChromeuser Datadefault')
#
# options.add_extension(r"C:UsersRADEONDocumentsWeb DriverSeleniumexs.crx")

# driver = webdriver.Chrome(
# executable_path="C:\Users\RADEON\Documents\Web Driver\chrome Driver\chromedriver.exe",
# chrome_options=options
# )
#
# driver = webdriver.Firefox()
#
# driver.get("https://www.runt.com.co/consultaCiudadana/#/consultaVehiculo")
# assert "Consulta Ciudadano - RUNT" in driver.title
#
# wait = WebDriverWait(driver, 2)
# wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))
#
#
# wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))


class Runt:

def __init__(self, placa, nit, time):
self.placa = placa
self.nit = nit
self.options = webdriver.ChromeOptions()
self.options.add_extension(
r"C:UsersRADEONDocumentsWeb Drivercp.crx")

self.driver = webdriver.Chrome(
chrome_options=self.options)

self.wait = WebDriverWait(self.driver, time)
self.wait_API = WebDriverWait(self.driver, 150)

def closeBrowser(self):
self.driver.close()

def run(self):

driver = self.driver
wait = self.wait
wait_api = self.wait_API
driver.get("https://www.runt.com.co/consultaCiudadana/#/consultaVehiculo")

wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))
placa = driver.find_element_by_id('noPlaca')
placa.clear()
placa.send_keys(self.placa)

wait.until(EC.presence_of_element_located((By.NAME, "noDocumento")))
owner = driver.find_element_by_name('noDocumento')
owner.clear()
owner.send_keys(self.nit)

# /html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]

wait_api.until(EC.presence_of_element_located((
By.XPATH, "//*[@id='captcha']/div/div[2]/a[1]")))

while (driver.find_element_by_xpath("//*[@id='captcha']/div/div[2]/a[1]").get_attribute("innerText") != "Solved"):
print("Search Solution....")
print("solution found...")

if(driver.find_element_by_xpath("//*[@id='captcha']/div/div[2]/a[1]").get_attribute("innerText") == "Solved"):
driver.find_element_by_xpath(
"/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[1]/div[3]/div[2]/div/div/form/div[8]/button").click()

WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()

vigente = driver.find_element_by_xpath(
"//*[@id='pnlRevisionTecnicoMecanicaNacional']/div/div/div/table/tbody/tr[1]/td[5]")

print(vigente.get_attribute("innerText"))


runt2 = Runt("aqd470", 63364079, 2)
# runt1 = Runt("aqd470", 45884847, 2)
#
# thread1 = threading.Thread(target=runt1.run)
thread2 = threading.Thread(target=runt2.run)
#
# thread1.start()
thread2.start()
# r'C:UsersRADEONDocumentsWeb Drivercsv.csv'


Ignore the threads was doing some tests.



When running this program on the aforementioned web waiting to solve the I am not a robot and send the form, and the code appears that I want to get the information



but the information does not appear in the html until clicking on the following div



<div class="panel-heading" ng-click="togglePanel('pnlRevisionTecnicoMecanicaNacional');
consultarDetalle('RevisionTecnicoMecanicaNacional')">
<h4 class="panel-title">
<i class="i_hoja s_25_o1 ib"></i>
<a> Certificado de revisión técnico mécanica y de gases (RTM)</a>
</h4>
</div>


U can use this example data to enter "AFD329" For Nplaca,"6656954" For Documento



The other fields can be left as default
I need to click on that element to load the rest of the query would appreciate a lot if you can help me










share|improve this question
























  • driver.find_element_by_xpath( "/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]/h4/a").click()

    – ArKaDiA
    Nov 15 '18 at 3:19











  • it could be dynamic html, can you post url of the page?

    – ewwink
    Nov 15 '18 at 4:10











  • which element you want to interact ?

    – cruisepandey
    Nov 15 '18 at 5:07











  • Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry link

    – ArKaDiA
    Nov 16 '18 at 0:59












  • @ArKaDiA Update the question with the Manual Steps you are trying to Automate and the error stack trace (if any)

    – DebanjanB
    Nov 16 '18 at 5:45















0















Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry



What I want to try is to automate the access to a web that I leave and link here
RUNT



The first part I have solved that is to enter the data to the form and resolve the im not to robot in send



I'm going to post all the code in python



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

import pandas as pd
import threading
import time
import csv
import os


# options = webdriver.ChromeOptions()
# options.add_argument(
# r'user-data-dir=C:UsersRADEONAppDataLocalGoogleChromeuser Datadefault')
#
# options.add_extension(r"C:UsersRADEONDocumentsWeb DriverSeleniumexs.crx")

# driver = webdriver.Chrome(
# executable_path="C:\Users\RADEON\Documents\Web Driver\chrome Driver\chromedriver.exe",
# chrome_options=options
# )
#
# driver = webdriver.Firefox()
#
# driver.get("https://www.runt.com.co/consultaCiudadana/#/consultaVehiculo")
# assert "Consulta Ciudadano - RUNT" in driver.title
#
# wait = WebDriverWait(driver, 2)
# wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))
#
#
# wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))


class Runt:

def __init__(self, placa, nit, time):
self.placa = placa
self.nit = nit
self.options = webdriver.ChromeOptions()
self.options.add_extension(
r"C:UsersRADEONDocumentsWeb Drivercp.crx")

self.driver = webdriver.Chrome(
chrome_options=self.options)

self.wait = WebDriverWait(self.driver, time)
self.wait_API = WebDriverWait(self.driver, 150)

def closeBrowser(self):
self.driver.close()

def run(self):

driver = self.driver
wait = self.wait
wait_api = self.wait_API
driver.get("https://www.runt.com.co/consultaCiudadana/#/consultaVehiculo")

wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))
placa = driver.find_element_by_id('noPlaca')
placa.clear()
placa.send_keys(self.placa)

wait.until(EC.presence_of_element_located((By.NAME, "noDocumento")))
owner = driver.find_element_by_name('noDocumento')
owner.clear()
owner.send_keys(self.nit)

# /html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]

wait_api.until(EC.presence_of_element_located((
By.XPATH, "//*[@id='captcha']/div/div[2]/a[1]")))

while (driver.find_element_by_xpath("//*[@id='captcha']/div/div[2]/a[1]").get_attribute("innerText") != "Solved"):
print("Search Solution....")
print("solution found...")

if(driver.find_element_by_xpath("//*[@id='captcha']/div/div[2]/a[1]").get_attribute("innerText") == "Solved"):
driver.find_element_by_xpath(
"/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[1]/div[3]/div[2]/div/div/form/div[8]/button").click()

WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()

vigente = driver.find_element_by_xpath(
"//*[@id='pnlRevisionTecnicoMecanicaNacional']/div/div/div/table/tbody/tr[1]/td[5]")

print(vigente.get_attribute("innerText"))


runt2 = Runt("aqd470", 63364079, 2)
# runt1 = Runt("aqd470", 45884847, 2)
#
# thread1 = threading.Thread(target=runt1.run)
thread2 = threading.Thread(target=runt2.run)
#
# thread1.start()
thread2.start()
# r'C:UsersRADEONDocumentsWeb Drivercsv.csv'


Ignore the threads was doing some tests.



When running this program on the aforementioned web waiting to solve the I am not a robot and send the form, and the code appears that I want to get the information



but the information does not appear in the html until clicking on the following div



<div class="panel-heading" ng-click="togglePanel('pnlRevisionTecnicoMecanicaNacional');
consultarDetalle('RevisionTecnicoMecanicaNacional')">
<h4 class="panel-title">
<i class="i_hoja s_25_o1 ib"></i>
<a> Certificado de revisión técnico mécanica y de gases (RTM)</a>
</h4>
</div>


U can use this example data to enter "AFD329" For Nplaca,"6656954" For Documento



The other fields can be left as default
I need to click on that element to load the rest of the query would appreciate a lot if you can help me










share|improve this question
























  • driver.find_element_by_xpath( "/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]/h4/a").click()

    – ArKaDiA
    Nov 15 '18 at 3:19











  • it could be dynamic html, can you post url of the page?

    – ewwink
    Nov 15 '18 at 4:10











  • which element you want to interact ?

    – cruisepandey
    Nov 15 '18 at 5:07











  • Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry link

    – ArKaDiA
    Nov 16 '18 at 0:59












  • @ArKaDiA Update the question with the Manual Steps you are trying to Automate and the error stack trace (if any)

    – DebanjanB
    Nov 16 '18 at 5:45













0












0








0








Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry



What I want to try is to automate the access to a web that I leave and link here
RUNT



The first part I have solved that is to enter the data to the form and resolve the im not to robot in send



I'm going to post all the code in python



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

import pandas as pd
import threading
import time
import csv
import os


# options = webdriver.ChromeOptions()
# options.add_argument(
# r'user-data-dir=C:UsersRADEONAppDataLocalGoogleChromeuser Datadefault')
#
# options.add_extension(r"C:UsersRADEONDocumentsWeb DriverSeleniumexs.crx")

# driver = webdriver.Chrome(
# executable_path="C:\Users\RADEON\Documents\Web Driver\chrome Driver\chromedriver.exe",
# chrome_options=options
# )
#
# driver = webdriver.Firefox()
#
# driver.get("https://www.runt.com.co/consultaCiudadana/#/consultaVehiculo")
# assert "Consulta Ciudadano - RUNT" in driver.title
#
# wait = WebDriverWait(driver, 2)
# wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))
#
#
# wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))


class Runt:

def __init__(self, placa, nit, time):
self.placa = placa
self.nit = nit
self.options = webdriver.ChromeOptions()
self.options.add_extension(
r"C:UsersRADEONDocumentsWeb Drivercp.crx")

self.driver = webdriver.Chrome(
chrome_options=self.options)

self.wait = WebDriverWait(self.driver, time)
self.wait_API = WebDriverWait(self.driver, 150)

def closeBrowser(self):
self.driver.close()

def run(self):

driver = self.driver
wait = self.wait
wait_api = self.wait_API
driver.get("https://www.runt.com.co/consultaCiudadana/#/consultaVehiculo")

wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))
placa = driver.find_element_by_id('noPlaca')
placa.clear()
placa.send_keys(self.placa)

wait.until(EC.presence_of_element_located((By.NAME, "noDocumento")))
owner = driver.find_element_by_name('noDocumento')
owner.clear()
owner.send_keys(self.nit)

# /html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]

wait_api.until(EC.presence_of_element_located((
By.XPATH, "//*[@id='captcha']/div/div[2]/a[1]")))

while (driver.find_element_by_xpath("//*[@id='captcha']/div/div[2]/a[1]").get_attribute("innerText") != "Solved"):
print("Search Solution....")
print("solution found...")

if(driver.find_element_by_xpath("//*[@id='captcha']/div/div[2]/a[1]").get_attribute("innerText") == "Solved"):
driver.find_element_by_xpath(
"/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[1]/div[3]/div[2]/div/div/form/div[8]/button").click()

WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()

vigente = driver.find_element_by_xpath(
"//*[@id='pnlRevisionTecnicoMecanicaNacional']/div/div/div/table/tbody/tr[1]/td[5]")

print(vigente.get_attribute("innerText"))


runt2 = Runt("aqd470", 63364079, 2)
# runt1 = Runt("aqd470", 45884847, 2)
#
# thread1 = threading.Thread(target=runt1.run)
thread2 = threading.Thread(target=runt2.run)
#
# thread1.start()
thread2.start()
# r'C:UsersRADEONDocumentsWeb Drivercsv.csv'


Ignore the threads was doing some tests.



When running this program on the aforementioned web waiting to solve the I am not a robot and send the form, and the code appears that I want to get the information



but the information does not appear in the html until clicking on the following div



<div class="panel-heading" ng-click="togglePanel('pnlRevisionTecnicoMecanicaNacional');
consultarDetalle('RevisionTecnicoMecanicaNacional')">
<h4 class="panel-title">
<i class="i_hoja s_25_o1 ib"></i>
<a> Certificado de revisión técnico mécanica y de gases (RTM)</a>
</h4>
</div>


U can use this example data to enter "AFD329" For Nplaca,"6656954" For Documento



The other fields can be left as default
I need to click on that element to load the rest of the query would appreciate a lot if you can help me










share|improve this question
















Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry



What I want to try is to automate the access to a web that I leave and link here
RUNT



The first part I have solved that is to enter the data to the form and resolve the im not to robot in send



I'm going to post all the code in python



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

import pandas as pd
import threading
import time
import csv
import os


# options = webdriver.ChromeOptions()
# options.add_argument(
# r'user-data-dir=C:UsersRADEONAppDataLocalGoogleChromeuser Datadefault')
#
# options.add_extension(r"C:UsersRADEONDocumentsWeb DriverSeleniumexs.crx")

# driver = webdriver.Chrome(
# executable_path="C:\Users\RADEON\Documents\Web Driver\chrome Driver\chromedriver.exe",
# chrome_options=options
# )
#
# driver = webdriver.Firefox()
#
# driver.get("https://www.runt.com.co/consultaCiudadana/#/consultaVehiculo")
# assert "Consulta Ciudadano - RUNT" in driver.title
#
# wait = WebDriverWait(driver, 2)
# wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))
#
#
# wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))


class Runt:

def __init__(self, placa, nit, time):
self.placa = placa
self.nit = nit
self.options = webdriver.ChromeOptions()
self.options.add_extension(
r"C:UsersRADEONDocumentsWeb Drivercp.crx")

self.driver = webdriver.Chrome(
chrome_options=self.options)

self.wait = WebDriverWait(self.driver, time)
self.wait_API = WebDriverWait(self.driver, 150)

def closeBrowser(self):
self.driver.close()

def run(self):

driver = self.driver
wait = self.wait
wait_api = self.wait_API
driver.get("https://www.runt.com.co/consultaCiudadana/#/consultaVehiculo")

wait.until(EC.presence_of_element_located((By.ID, "noPlaca")))
placa = driver.find_element_by_id('noPlaca')
placa.clear()
placa.send_keys(self.placa)

wait.until(EC.presence_of_element_located((By.NAME, "noDocumento")))
owner = driver.find_element_by_name('noDocumento')
owner.clear()
owner.send_keys(self.nit)

# /html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]

wait_api.until(EC.presence_of_element_located((
By.XPATH, "//*[@id='captcha']/div/div[2]/a[1]")))

while (driver.find_element_by_xpath("//*[@id='captcha']/div/div[2]/a[1]").get_attribute("innerText") != "Solved"):
print("Search Solution....")
print("solution found...")

if(driver.find_element_by_xpath("//*[@id='captcha']/div/div[2]/a[1]").get_attribute("innerText") == "Solved"):
driver.find_element_by_xpath(
"/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[1]/div[3]/div[2]/div/div/form/div[8]/button").click()

WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()

vigente = driver.find_element_by_xpath(
"//*[@id='pnlRevisionTecnicoMecanicaNacional']/div/div/div/table/tbody/tr[1]/td[5]")

print(vigente.get_attribute("innerText"))


runt2 = Runt("aqd470", 63364079, 2)
# runt1 = Runt("aqd470", 45884847, 2)
#
# thread1 = threading.Thread(target=runt1.run)
thread2 = threading.Thread(target=runt2.run)
#
# thread1.start()
thread2.start()
# r'C:UsersRADEONDocumentsWeb Drivercsv.csv'


Ignore the threads was doing some tests.



When running this program on the aforementioned web waiting to solve the I am not a robot and send the form, and the code appears that I want to get the information



but the information does not appear in the html until clicking on the following div



<div class="panel-heading" ng-click="togglePanel('pnlRevisionTecnicoMecanicaNacional');
consultarDetalle('RevisionTecnicoMecanicaNacional')">
<h4 class="panel-title">
<i class="i_hoja s_25_o1 ib"></i>
<a> Certificado de revisión técnico mécanica y de gases (RTM)</a>
</h4>
</div>


U can use this example data to enter "AFD329" For Nplaca,"6656954" For Documento



The other fields can be left as default
I need to click on that element to load the rest of the query would appreciate a lot if you can help me







python selenium xpath css-selectors webdriverwait






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 16:36







ArKaDiA

















asked Nov 15 '18 at 3:18









ArKaDiAArKaDiA

112




112












  • driver.find_element_by_xpath( "/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]/h4/a").click()

    – ArKaDiA
    Nov 15 '18 at 3:19











  • it could be dynamic html, can you post url of the page?

    – ewwink
    Nov 15 '18 at 4:10











  • which element you want to interact ?

    – cruisepandey
    Nov 15 '18 at 5:07











  • Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry link

    – ArKaDiA
    Nov 16 '18 at 0:59












  • @ArKaDiA Update the question with the Manual Steps you are trying to Automate and the error stack trace (if any)

    – DebanjanB
    Nov 16 '18 at 5:45

















  • driver.find_element_by_xpath( "/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]/h4/a").click()

    – ArKaDiA
    Nov 15 '18 at 3:19











  • it could be dynamic html, can you post url of the page?

    – ewwink
    Nov 15 '18 at 4:10











  • which element you want to interact ?

    – cruisepandey
    Nov 15 '18 at 5:07











  • Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry link

    – ArKaDiA
    Nov 16 '18 at 0:59












  • @ArKaDiA Update the question with the Manual Steps you are trying to Automate and the error stack trace (if any)

    – DebanjanB
    Nov 16 '18 at 5:45
















driver.find_element_by_xpath( "/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]/h4/a").click()

– ArKaDiA
Nov 15 '18 at 3:19





driver.find_element_by_xpath( "/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]/h4/a").click()

– ArKaDiA
Nov 15 '18 at 3:19













it could be dynamic html, can you post url of the page?

– ewwink
Nov 15 '18 at 4:10





it could be dynamic html, can you post url of the page?

– ewwink
Nov 15 '18 at 4:10













which element you want to interact ?

– cruisepandey
Nov 15 '18 at 5:07





which element you want to interact ?

– cruisepandey
Nov 15 '18 at 5:07













Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry link

– ArKaDiA
Nov 16 '18 at 0:59






Hello everyone forgive I think I can not really explain my problem, I will try again, if they can not understand me very well is that sometimes my English written fails a lot sorry link

– ArKaDiA
Nov 16 '18 at 0:59














@ArKaDiA Update the question with the Manual Steps you are trying to Automate and the error stack trace (if any)

– DebanjanB
Nov 16 '18 at 5:45





@ArKaDiA Update the question with the Manual Steps you are trying to Automate and the error stack trace (if any)

– DebanjanB
Nov 16 '18 at 5:45












2 Answers
2






active

oldest

votes


















1














Based on your xpath you are locating the <a> under <h4>.



Element may required some time to get visible, for that try explicitwait until element get visible.



Import below packages :



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


Try with below code :



element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((CSS_SELECTOR, ".panel-title a")))
element.click()


Its bad practice to use absolute xpath, use relative xpath instead. or try CSS Selector over the xpath.






share|improve this answer
































    0














    @NarendraR's answer was in the right direction.



    As per your question and the HTML you have provided, the attribute ng-click is applied to the <div> node which is generally not clickable. So instead of attempting to click the ancestor <div> node you need to invoke the click() on one of it's descendant node i.e. the <a> node.



    Again as the element is an Angular element you need to induce WebDriverWait and you can use either of the following solutions:




    • Using PARTIAL_LINK_TEXT:



      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "Certificado de revisión técnico mécanica y de gases"))).click()



    • Using CSS_SELECTOR:



      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()



    • Using XPATH:



      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='panel-heading']/h4[@class='panel-title']//a[contains(.,'Certificado de revisión técnico mécanica y de gases')]"))).click()



    • Note : You have to add the following imports :



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






    share|improve this answer























    • DebanjanB Thank you for your help but it does not work I understand what you mention to me, I appreciate your help expand the question to give you more information

      – ArKaDiA
      Nov 16 '18 at 1:15










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311909%2funable-to-click-on-a-div-with-selenium-ng-click-python%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Based on your xpath you are locating the <a> under <h4>.



    Element may required some time to get visible, for that try explicitwait until element get visible.



    Import below packages :



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


    Try with below code :



    element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((CSS_SELECTOR, ".panel-title a")))
    element.click()


    Its bad practice to use absolute xpath, use relative xpath instead. or try CSS Selector over the xpath.






    share|improve this answer





























      1














      Based on your xpath you are locating the <a> under <h4>.



      Element may required some time to get visible, for that try explicitwait until element get visible.



      Import below packages :



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


      Try with below code :



      element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((CSS_SELECTOR, ".panel-title a")))
      element.click()


      Its bad practice to use absolute xpath, use relative xpath instead. or try CSS Selector over the xpath.






      share|improve this answer



























        1












        1








        1







        Based on your xpath you are locating the <a> under <h4>.



        Element may required some time to get visible, for that try explicitwait until element get visible.



        Import below packages :



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


        Try with below code :



        element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((CSS_SELECTOR, ".panel-title a")))
        element.click()


        Its bad practice to use absolute xpath, use relative xpath instead. or try CSS Selector over the xpath.






        share|improve this answer















        Based on your xpath you are locating the <a> under <h4>.



        Element may required some time to get visible, for that try explicitwait until element get visible.



        Import below packages :



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


        Try with below code :



        element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((CSS_SELECTOR, ".panel-title a")))
        element.click()


        Its bad practice to use absolute xpath, use relative xpath instead. or try CSS Selector over the xpath.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 15 '18 at 6:32









        DebanjanB

        43.5k104386




        43.5k104386










        answered Nov 15 '18 at 5:32









        NarendraRNarendraR

        3,92361946




        3,92361946























            0














            @NarendraR's answer was in the right direction.



            As per your question and the HTML you have provided, the attribute ng-click is applied to the <div> node which is generally not clickable. So instead of attempting to click the ancestor <div> node you need to invoke the click() on one of it's descendant node i.e. the <a> node.



            Again as the element is an Angular element you need to induce WebDriverWait and you can use either of the following solutions:




            • Using PARTIAL_LINK_TEXT:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "Certificado de revisión técnico mécanica y de gases"))).click()



            • Using CSS_SELECTOR:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()



            • Using XPATH:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='panel-heading']/h4[@class='panel-title']//a[contains(.,'Certificado de revisión técnico mécanica y de gases')]"))).click()



            • Note : You have to add the following imports :



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






            share|improve this answer























            • DebanjanB Thank you for your help but it does not work I understand what you mention to me, I appreciate your help expand the question to give you more information

              – ArKaDiA
              Nov 16 '18 at 1:15















            0














            @NarendraR's answer was in the right direction.



            As per your question and the HTML you have provided, the attribute ng-click is applied to the <div> node which is generally not clickable. So instead of attempting to click the ancestor <div> node you need to invoke the click() on one of it's descendant node i.e. the <a> node.



            Again as the element is an Angular element you need to induce WebDriverWait and you can use either of the following solutions:




            • Using PARTIAL_LINK_TEXT:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "Certificado de revisión técnico mécanica y de gases"))).click()



            • Using CSS_SELECTOR:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()



            • Using XPATH:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='panel-heading']/h4[@class='panel-title']//a[contains(.,'Certificado de revisión técnico mécanica y de gases')]"))).click()



            • Note : You have to add the following imports :



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






            share|improve this answer























            • DebanjanB Thank you for your help but it does not work I understand what you mention to me, I appreciate your help expand the question to give you more information

              – ArKaDiA
              Nov 16 '18 at 1:15













            0












            0








            0







            @NarendraR's answer was in the right direction.



            As per your question and the HTML you have provided, the attribute ng-click is applied to the <div> node which is generally not clickable. So instead of attempting to click the ancestor <div> node you need to invoke the click() on one of it's descendant node i.e. the <a> node.



            Again as the element is an Angular element you need to induce WebDriverWait and you can use either of the following solutions:




            • Using PARTIAL_LINK_TEXT:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "Certificado de revisión técnico mécanica y de gases"))).click()



            • Using CSS_SELECTOR:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()



            • Using XPATH:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='panel-heading']/h4[@class='panel-title']//a[contains(.,'Certificado de revisión técnico mécanica y de gases')]"))).click()



            • Note : You have to add the following imports :



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






            share|improve this answer













            @NarendraR's answer was in the right direction.



            As per your question and the HTML you have provided, the attribute ng-click is applied to the <div> node which is generally not clickable. So instead of attempting to click the ancestor <div> node you need to invoke the click() on one of it's descendant node i.e. the <a> node.



            Again as the element is an Angular element you need to induce WebDriverWait and you can use either of the following solutions:




            • Using PARTIAL_LINK_TEXT:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "Certificado de revisión técnico mécanica y de gases"))).click()



            • Using CSS_SELECTOR:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.panel.panel-default>div.panel-heading>h4.panel-title a"))).click()



            • Using XPATH:



              WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='panel-heading']/h4[@class='panel-title']//a[contains(.,'Certificado de revisión técnico mécanica y de gases')]"))).click()



            • Note : You have to add the following imports :



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







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 15 '18 at 7:21









            DebanjanBDebanjanB

            43.5k104386




            43.5k104386












            • DebanjanB Thank you for your help but it does not work I understand what you mention to me, I appreciate your help expand the question to give you more information

              – ArKaDiA
              Nov 16 '18 at 1:15

















            • DebanjanB Thank you for your help but it does not work I understand what you mention to me, I appreciate your help expand the question to give you more information

              – ArKaDiA
              Nov 16 '18 at 1:15
















            DebanjanB Thank you for your help but it does not work I understand what you mention to me, I appreciate your help expand the question to give you more information

            – ArKaDiA
            Nov 16 '18 at 1:15





            DebanjanB Thank you for your help but it does not work I understand what you mention to me, I appreciate your help expand the question to give you more information

            – ArKaDiA
            Nov 16 '18 at 1:15

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311909%2funable-to-click-on-a-div-with-selenium-ng-click-python%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3