2

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:\Users\RADEON\AppData\Local\Google\Chrome\user Data\default')
#
# options.add_extension(r"C:\Users\RADEON\Documents\Web Driver\Selenium\exs.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:\Users\RADEON\Documents\Web Driver\cp.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:\Users\RADEON\Documents\Web Driver\csv.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 the TRACEBACK IS

Traceback (most recent call last):
  File "C:\Users\RADEON\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Users\RADEON\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "bypass.py", line 86, in run
    "/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]").click()
  File "C:\Users\RADEON\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Users\RADEON\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\RADEON\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\RADEON\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable
  (Session info: chrome=70.0.3538.102)
  (Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.16299 x86_64)
ArKaDiA
  • 21
  • 4
  • 1. The error trace you have posted is error on `"/html/body/div[1]/div/div[1]/div[2]/div[1]/div[2]/div[7]/div[1]").click()`, but this is not part of the code you have shared. Please check and update the latest code/trace in the question. 2. I could not find any element with this xpath `//*[@id='captcha']/div/div[2]/a[1]`, what element are you trying to click on? – Kamal Nov 20 '18 at 01:29

0 Answers0