Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: dian1919 en 7 Marzo 2023, 04:51 am



Título: Click en boton selenium y python
Publicado por: dian1919 en 7 Marzo 2023, 04:51 am
Saludos estoy tratando de hacer un click en un boton con selenium y pyton el boton en la pagina su sección de codigo en la pagina es

Código
  1. <a class="start-button" href="javascript:" id="convert1">
  2.                                    Start
  3.                                    <i class="fa fa-angle-right fa-5"></i>
  4.                                </a>

para dar click en python



Código
  1. # getting the button by class name
  2. button = driver.find_element_by_class_name("Start")
  3.  
  4. # clicking on the button
  5. button.click()
  6.  




me sale este error
Traceback (most recent call last):
  File "C:\Users\WIND\Desktop\dat\prueba.py", line 10, in <module>
    button = driver.find_element_by_class_name("Start")
AttributeError: 'WebDriver' object has no attribute 'find_element_by_class_name'


Título: Re: Click en boton selenium y python
Publicado por: reymosquito en 7 Marzo 2023, 11:39 am
¿y cómo está declarado driver?
otra cosa el nombre de la clase es start-button y no Start


Título: Re: Click en boton selenium y python
Publicado por: Danielㅤ en 7 Marzo 2023, 16:58 pm
Hola, como estas cargando la librería de Selenium?


Saludos


Título: Re: Click en boton selenium y python
Publicado por: dian1919 en 7 Marzo 2023, 18:28 pm
Código
  1. from logging import error
  2. from selenium import webdriver
  3. from selenium.webdriver.support.ui import WebDriverWait
  4. import time
  5.  
  6.  
  7.  
  8.  
  9. # initialize the Chrome driver
  10. driver = webdriver.Chrome(r"chromedriver")
  11. # head to github login page
  12. driver.get("https://************** pagina personal")
  13. time.sleep(5)  # pauses execution for 5 seconds
  14.  
  15. # getting the button by class name
  16. button = driver.find_element_by_class_name("Start")
  17.  
  18. # clicking on the button
  19. button.click()

Código
  1. <a class="start-button" href="javascript:" id="convert1">
  2.                                    Start
  3.                                    <i class="fa fa-angle-right fa-5"></i>
  4.                                </a>