#๐Ÿ”’ Using Selenium to make a Automatic Form Filler

13 messages ยท Page 1 of 1 (latest)

tired ermineBOT
#

@eternal marten

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

eternal marten
#
from selenium import webdriver
import time

web = webdriver.Chrome()
web.get('https://d/forms/d/e/1FAIpQLSek4lvyKCkjeKHJwRRSUdsNb4WCIohFNlog7YjeWVzmEr3DQQ/viewform')

time.sleep(2)

LastName = "Kattimani"
last = web.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[2]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/input')
last.send_keys(LastName)

FirstName = "Rishab"
first = web.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[2]/div[2]/div/div/div[2]/div/div[1]/div/div[1]/input')
first.send_keys(FirstName)

RadioButtonPeriod = web.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[2]/div[3]/div/div/div[2]/div[1]/div/span/div/div[2]/label/div/div[1]/div/div[3]/div')
RadioButtonPeriod.click()

Submit = web.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[3]/div[1]/div/div/span')
Submit.click()

get_confirmation_div_text = web.find_element_by_css_selector('.freebirdFormviewerViewResponseConfirmationMessage')
print(get_confirmation_div_text.text)
if ((get_confirmation_div_text.text) == "Thank you for attending"):
    print ("Test Was Successful")
else:
    print("Test Was Not Successful")
#

Here is a sample piece of code and the error I am experiencing:

Traceback (most recent call last):
File "C:\Users\Name\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\Name\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Name\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Name\Downloads\New folder\AutomaticFormFiller.py", line 4, in <module>
web = webdriver.Chrome()
File "C:\Users\Name\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in init
super(WebDriver, self).init(DesiredCapabilities.CHROME['browserName'], "goog",
File "C:\Users\Name\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 89, in init
self.service.start()
File "C:\Users\Name\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

#

The link prompts me to download a 32 bit version of the windows program

candid geyser
flint sedge
eternal marten
# candid geyser why do you want to automatically fill out forms?

Hello sorry for the slow responce, this will be designed for Roblox as a method of quickly being able to fill out forms to remove content breakers from the platform here is an example of my current code:


from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
import requests
import time

def get_id(name):
    try:
        response = requests.post(
            'https://users.roblox.com/v1/usernames/users',
            json={"usernames": [name], "excludeBannedUsers": True}
        )
        response.raise_for_status()  # Raise HTTPError for bad status codes
        data = response.json()['data'][0]
        return data['id']
    except requests.exceptions.RequestException as e:
        print(f"An error occurred: {e}")
        return None
    except Exception as e:
        print(f"An unexpected error occurred: {e}")
        return None

def send_report(username):
    user_id = get_id(username)
    if user_id:
        profile_link = f"https://www.roblox.com/users/{user_id}/profile"
        message = (f"I am writing to report an account with an inappropriate username on your platform. "
                   f"The username in question is {username}. This username violates the community guidelines "
                   f"as it contains offensive language/imagery and is not suitable for the platform.\n\n"
                   f"I came across this username while browsing the website and immediately recognized its "
                   f"inappropriate nature. Such usernames not only foster a negative environment but also "
                   f"go against the values of inclusivity and respect that the platform strives to maintain.\n\n"
                   f"I kindly request that the necessary actions be taken to address this issue promptly. This "
                   f"may include reaching out to the account holder to change their username to something more "
                   f"appropriate or suspending the account if deemed necessary.\n\n"
                   f"Thank you for your attention to this matter. I believe that by promptly addressing "
                   f"inappropriate content, we can contribute to a safer and more respectful community.\n\n"
                   f"Profile Link: {profile_link}\n\n"
                   f"Sincerely,\nPeter")
        print(message)
        verify_title(message, profile_link)
    else:
        print("User not found or an error occurred.")

def verify_title(message, profile_link):
    options = webdriver.ChromeOptions()
    service = ChromeService(ChromeDriverManager().install())
    driver = webdriver.Chrome(service=service, options=options)

    # Open the URL
    url = "https://www.roblox.com/illegal-content-reporting"
    driver.get(url)
    time.sleep(2)
    Reason = driver.find_element_by_xpath('//*[@id="illegal-description-input"]/textarea')
    Reason.send_keys(message)
    Name = driver.find_element_by_xpath('//*[@id="reporter-info-name"]/input')
    Name.send_keys("Peter")
    Email = driver.find_element_by_xpath('//*[@id="reporter-info-email"]/input')
    Email.send_keys("[email protected]")
    ProfileLink = driver.find_element_by_xpath('//*[@id="url-input"]/input')
    ProfileLink.send_keys(profile_link)
    OptionType = driver.find_element_by_xpath('//*[@id="ChildSexualExploitation-radio"]')
    OptionType.click()
    dropdownbox = driver.find_elements(by=By.TAG_NAME, value = "Option")
    i=0
    while i < len(dropdownbox):
        if(dropdownbox[i].text == "France"):
            dropdownbox[i].click()
        i+=1
    input("Press Enter to close the browser...")  # Wait for user input to close the browser
    driver.quit()  # Close the browser when user presses Enter

def main():
    username = input("Enter the username: ")
    send_report(username)

if __name__ == "__main__":
    main()
#

I've basically completed it apart from being unable to figure out the muliselection of buttons or the dropdown box..

#

@candid geyser

tired ermineBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.