Python Forum
Trying to make a bot to connect on discord with Selenium Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to make a bot to connect on discord with Selenium Python
#1
Trying to make a bot to connect on discord with Selenium Python: I've been trying to make a bot to connect to my discord.

Imports needed are listed below:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
The following code is my script - defining DiscordBot:

class DiscordBot:

def __init__(self, email, password):
    self.email = email
    self.password = password
    self.driver = webdriver.Firefox()

def closeBrowser(self):
    self.driver.close()      

def login(self):
    driver = self.driver
    driver.get("https://discordapp.com/login")
    browser = webdriver.Firefox()
    email = browser.find_element("register-email")
    email.send_keys("[email protected]")
    password = browser.find_element("register-password")
    password.send_keys("my password")
    browser.find_element_by_name("login").click()
    time.sleep(2)
However, my problem is when the above code runs, it produces the following error:

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: 
Message: unknown variant `register-email`, expected one of `css selector`, `link text`,
`partial link text`, `tag name`, `xpath` at line 1 column 26
Reply
#2
Indentation of methods is incorrect in class DiscordBot needs indent of 4

add to imports:
from selenium.webdriver.common.by import By
change find_element lines similar to:
email = browser.find_element(By.NAME, "register-email")
Reply
#3
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select

driver = webdriver.Chrome()

driver.get("https://discord.com/login")
time.sleep(6)

username_input = driver.find_element_by_name('email')
username_input.send_keys("enter-your-username-here")


password_input = driver.find_element_by_name('password')
password_input.send_keys("Enter-your-password-here")


login_button = driver.find_element_by_xpath('//*[@id="app-mount"]/div[2]/div/div[2]/div/div/form/div/div/div[1]/div[3]/button[2]')
login_button.click()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  connect sql by python using txt. file dawid294 2 445 Jan-12-2024, 08:54 PM
Last Post: deanhystad
  How to Connect to PostgreSQL Through Jump Server and SSH Tunnel using Python? nishans 1 1,018 Jan-02-2024, 10:37 AM
Last Post: khanzain
  python connect to mssql wailoonho 7 1,616 Dec-07-2023, 02:06 AM
Last Post: wailoonho
  Using Python to connect to an XML ? jehoshua 12 1,995 Jul-11-2023, 12:34 AM
Last Post: jehoshua
  Looking for discord bot to make loop ping for address ip tinkode 0 1,836 Jul-26-2021, 03:51 PM
Last Post: tinkode
  Creating Discord Bot: Unused import statement 'import discord EyeballCandy 0 3,565 Feb-02-2020, 10:53 PM
Last Post: EyeballCandy
  How to connect Mysql databse with python and VSCode IDE madhusoodhananER 1 8,738 Oct-31-2019, 10:15 AM
Last Post: Larz60+
  Problem Discord Bot Python Kint 4 81,842 Aug-11-2019, 04:02 PM
Last Post: Kint
  Connect a Teradata DB to Python OscarBoots 10 8,890 Jan-31-2019, 10:23 PM
Last Post: OscarBoots
  Python connect to Sybase IQ FORTITUDE 1 4,794 Jan-24-2019, 02:14 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020