Search code examples
pythonhtmlseleniumpython-3.6

I have made a script that uses selenium in python3 to send messages but it doesn't work


This is my script (https://pastebin.com/dWLFvirn). I have used terminal to run the script but it shows error. Here is the screenshot(https://ibb.co/NSfLgL8)

I want to use "https://getlinks.info/slam-book/p/Shubha" as the link on which it has to work.

The system configuration I have is =>> 1. Kali Linux 2020.1b 32-Bit , 2. Python 3.7.5

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import hashlib
import string
import random

driver_location = "/home/kali/Desktop/geckodriver"

print('''\033[34m Starting Attack \033[34m''')

for i in range(10):


    driver=webdriver.Firefox(executable_path=driver_location)
    driver.get("https://getlinks.info/slam-book/p/Shubha")

    driver.implicitly_wait(60)

    firstbtn = driver.find_element_by_xpath('/html/body/div[1]/center/a[1]')
    firstbtn.click()

    firsttxtbx = driver.find_element_by_xpath('//*[@id="nametb"]')
    firsttxtbx.send_keys('I am Blackghost')

    scndbtn = driver.find_element_by_xpath('/html/body/div[2]/center/a')
    scndbtn.click()

    secondtxtbx = driver.find_element_by_xpath('//*[@id="ipQ0"]')
    secondtxtbx.send_keys('I have told you not to indulge in this websites')

    thdbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[1]/a')
    thdbtn.click()

    thirdtxtbx = driver.find_element_by_xpath('//*[@id="ipQ1"]')
    thirdtxtbx.send_keys('This websites allow multiple entry flaw.')

    frthbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[2]/a')
    frthbtn.click()

    fourthtxtbx = driver.find_element_by_xpath('//*[@id="ipQ2"]')
    fourthtxtbx.send_keys('Which is actually a vulnability')

    fthbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[3]/a')
    fthbtn.click()

    fifthtxtbx = driver.find_element_by_xpath('//*[@id="ipQ3"]')
    fifthtxtbx.send_keys('You must not use these types of websites.')

    sixthbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[4]/a')
    sixthbtn.click()

    sixthtxtbx = driver.find_element_by_xpath('//*[@id="ipQ4"]')
    sixthtxtbx.send_keys('And don\'nt ever share this types of links in any social medias. ')

    svnthbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[5]/a')
    svnthbtn.click()

    seventhtxtbx = driver.find_element_by_xpath('//*[@id="ipQ5"]')
    seventhtxtbx.send_keys('Specially in Whatsapp')

    eighthbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[6]/a')
    eighthbtn.click()

    eighthtxtbx = driver.find_element_by_xpath('//*[@id="ipQ6"]')
    eighthtxtbx.send_keys('We are Anonymous. We are legion.')

    nthbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[7]/a')
    nthbtn.click()

    ninethtxtbx = driver.find_element_by_xpath('//*[@id="ipQ7"]')
    ninethtxtbx.send_keys('We donot forget. We donot forgive.')

    tnthbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[8]/a')
    tnthbtn.click()

    tenthtxtbx = driver.find_element_by_xpath('//*[@id="ipQ8"]')
    tenthtxtbx.send_keys('You must have to give these warnings in whatsapp status.')

    elvnthbtn = driver.find_element_by_xpath('/html/body/div[3]/center/div/div[9]/a')
    elvnthbtn.click()

    send_finish = driver.find_element_by_xpath('/html/body/div[2]/div/div[3]/button[1]')
    send_finish.click()

    driver.close()
    driver.quit()

    print('Attack finished',i)

----------------------------------------------------------------------------------------------------

Solution

  • I have tried your code using chrome browser and hopefully it will work on firefox too. To address the issue you have to induce WebDriverWait for the element to be clickable before sending key to your input.

    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait as Wait
    
    driver = webdriver.Chrome(executable_path=r" path to chromedriver.exe")
    driver.maximize_window()
    
    
        driver.get("https://getlinks.info/slam-book/p/Shubha")
        main_window = driver.current_window_handle
        wait = WebDriverWait(driver, 20)
    
        wait.until(EC.element_to_be_clickable((By.XPATH, "//a[@class='button no-border-radius is-fullwidth is-medium animated infinite pulse']"))).click()
    
        wait.until(EC.element_to_be_clickable((By.ID, "nametb"))).send_keys('I am Blackghost')
    

    enter image description here

    updateed solution :

    driver.get("https://getlinks.info/slam-book/p/Shubha")
    
    wait = WebDriverWait(driver, 20)
    wait.until(EC.element_to_be_clickable((By.XPATH, "//a[@class='button no-border-radius is-fullwidth is-medium animated infinite pulse']"))).click()
    wait.until(EC.element_to_be_clickable((By.ID, "nametb"))).send_keys('I am Blackghost')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//a[contains(text(),'Next')]"))).click()
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ0']"))).send_keys('I have told you not to indulge in this websites')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='divQ0']//a[contains(@class,'button no-border-radius is-fullwidth is-medium')][contains(text(),'Next')]"))).click()
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ1']"))).send_keys('This websites allow multiple entry flaw.')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='divQ1']//a[contains(@class,'button no-border-radius is-fullwidth is-medium')][contains(text(),'Next')]"))).click()
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ2']"))).send_keys('Which is actually a vulnability')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='divQ2']//a[contains(@class,'button no-border-radius is-fullwidth is-medium')][contains(text(),'Next')]"))).click()
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ3']"))).send_keys('You must not use these types of websites.')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='divQ3']//a[contains(@class,'button no-border-radius is-fullwidth is-medium')][contains(text(),'Next')]"))).click()
    
    
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ4']"))).send_keys('And don\'nt ever share this types of links in any social medias.')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='divQ4']//a[contains(@class,'button no-border-radius is-fullwidth is-medium')][contains(text(),'Next')]"))).click()
    
    
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ5']"))).send_keys('Specially in Whatsapp')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='divQ5']//a[contains(@class,'button no-border-radius is-fullwidth is-medium')][contains(text(),'Next')]"))).click()
    
    
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ6']"))).send_keys('We are Anonymous. We are legion.')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='divQ6']//a[contains(@class,'button no-border-radius is-fullwidth is-medium')][contains(text(),'Next')]"))).click()
    
    
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ7']"))).send_keys('We donot forget. We donot forgive.')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='divQ7']//a[contains(@class,'button no-border-radius is-fullwidth is-medium')][contains(text(),'Next')]"))).click()
    
    
    wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='ipQ8']"))).send_keys('You must have to give these warnings in whatsapp status.')
    wait.until(EC.element_to_be_clickable((By.XPATH, "//a[contains(text(),'Finish')]"))).click()
    

    Output :

    enter image description here