elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  script en python con bucle, ayuda
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: script en python con bucle, ayuda  (Leído 2,637 veces)
kikian94

Desconectado Desconectado

Mensajes: 66


Ver Perfil
script en python con bucle, ayuda
« en: 7 Marzo 2014, 18:47 pm »

hola, soy novato en esto de los script y mas en python que nunca lo he visto, se C y java, el caso es que quiero crear un script con una funcionalidad muy basica:

Código
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.common.keys import Keys
  4. from selenium.webdriver.support.ui import Select
  5. from selenium.common.exceptions import NoSuchElementException
  6. import unittest, time, re
  7.  
  8. class Prueba3(unittest.TestCase):
  9.    def setUp(self):
  10.        self.driver = webdriver.Firefox()
  11.        self.driver.implicitly_wait(30)
  12.        self.base_url = "http://playfulbet.com/usuarios/"
  13.        self.verificationErrors = []
  14.        self.accept_next_alert = True
  15.  
  16.    def test_prueba3(self):
  17.        for
  18.        b = 4
  19.        i="1"
  20.        driver = self.driver
  21.        driver.get(self.base_url + i)
  22.        driver.find_element_by_link_text("Entra y juega").click()
  23.        driver.find_element_by_link_text("Logueate").click()
  24.        driver.find_element_by_name("commit").click()
  25.        driver.find_element_by_id("follow").click()
  26.        driver.find_element_by_css_selector("#add_friend > b").click()
  27.  
  28.    def is_element_present(self, how, what):
  29.        try: self.driver.find_element(by=how, value=what)
  30.        except NoSuchElementException, e: return False
  31.        return True
  32.  
  33.    def is_alert_present(self):
  34.        try: self.driver.switch_to_alert()
  35.        except NoAlertPresentException, e: return False
  36.        return True
  37.  
  38.    def close_alert_and_get_its_text(self):
  39.        try:
  40.            alert = self.driver.switch_to_alert()
  41.            alert_text = alert.text
  42.            if self.accept_next_alert:
  43.                alert.accept()
  44.            else:
  45.                alert.dismiss()
  46.            return alert_text
  47.        finally: self.accept_next_alert = True
  48.  
  49.    def tearDown(self):
  50.        self.driver.quit()
  51.        self.assertEqual([], self.verificationErrors)
  52.  
  53. if __name__ == "__main__":
  54.    unittest.main()
  55.  

haber, lo explico, quiero que el script sea capaz de acceder a todos os usuarios de la pagina y pinche en dos botones por usuario, pero no se como se pone eso en python, como añado un for y lo recorro? tendria que ser un bucle de 1 hasta 50000, he puesto un int pero no se como añadirlo a la direccion base, si lo hago con un string si me deja pero no se como incrementar el valor de dentro del string, alguien me echa una ayuda?. si lo quisiera hacer en java, para ejecutarlo luego como lo haria?


En línea

kikian94

Desconectado Desconectado

Mensajes: 66


Ver Perfil
Re: script en python con bucle, ayuda
« Respuesta #1 en: 8 Marzo 2014, 16:23 pm »

sigo intentandolo pero no consigo hacer nada, solo consigo que me meta en la pagina principal pero no me pulsa ningun boton:
Código
  1. from selenium import webdriver
  2. from selenium.webdriver.common.keys import Keys
  3.  
  4. driver = webdriver.Firefox()
  5. driver.get("http://www.playfullbet.com")
  6.  
  7. elem = driver.find_element_by_link_text("Entra y juega").click()
  8. username = driver.find_element_by_name('username')
  9.  
  10. driver.close()

tendria que pulsar en el boton entra y juega, luego en loquear, introducir los datos y una vez que este dentro de la pagina ir pulsando en los dos botones que cite antes en cada usuario con un bucle, pero no hace nada, solo carga la pagina y se para


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[python] ayuda con script ¨^^(SOLUCIONADO)
Scripting
EvilGoblin 3 3,503 Último mensaje 17 Abril 2010, 03:02 am
por Novlucker
Ayuda Python -script generador numerico-
Scripting
lithium93 2 3,186 Último mensaje 30 Octubre 2010, 00:17 am
por criskapunk
Ayuda con script python
Scripting
Xenomorfo77 5 3,710 Último mensaje 4 Mayo 2012, 02:13 am
por Xenomorfo77
[Ayuda]Como puedo convertir script Python a ejecutable exe
Scripting
Proxmond 1 2,531 Último mensaje 17 Junio 2014, 23:10 pm
por EzianGES
[PYTHON][AYUDA] Script respaldo automático mysql
Scripting
LaThortilla (Effort) 1 3,349 Último mensaje 14 Marzo 2015, 19:04 pm
por LaThortilla (Effort)
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines