Interacting with Discord Using Selenium in Python

Greetings, I am encountering a problem with the code snippet below. The specific issue is that after opening a submenu and attempting to send down arrow keys, it does not work properly unless I use a multiplier like *100. Any assistance on this matter would be greatly appreciated.

users = driver.find_elements_by_class_name("name-uJV0GL")
for user in users:
    addedUsers = driver.find_elements_by_class_name("name-uJV0GL")
    for addedUser in addedUsers:
        if addedUser not in users:
            users.append(addedUser)

    actions = ActionChains(driver)
    driver.implicitly_wait(15)

    try:
        actions.move_to_element(user).click().perform()
        driver.implicitly_wait(15)
        userDetails = driver.find_element_by_class_name("nameTag-m8r81H")
    
        if userDetails.text not in userList:
            print(userDetails.text)
            userList.append(userDetails.text)
            lastUser = user
            actions = ActionChains(driver)
            actions.context_click(user).send_keys(Keys.ARROW_DOWN * 4).send_keys(Keys.ENTER).perform()
            id = clipboard.paste()
            print(id)
            time.sleep(10)

    except Exception as e:
        
        print("There was an issue, ", e)
        break

Answer №1

If I were coding in Python, instead of using this line:

actions.context_click(user).send_keys(Keys.ARROW_DOWN * 4).send_keys(Keys.ENTER).perform()

I would suggest trying the following code:

actions.context_click(user).perform()
for i in range(4):
    actions.send_keys(Keys.ARROW_DOWN).perform()
actions.send_keys(Keys.ENTER).perform()

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

requesting an individual to provide a document for safekeeping

My goal is to prompt the user for a file name and then save some information in that file. This is the part of the program that I've written: if saving == 1: ask=raw_input("Please enter the filename: ") fileout=open(ask.csv,"w") ...

A guide to resolving the ERR_TUNNEL_CONNECTION_FAILED proxy server error using the free-proxy service

After following a tutorial on consolidating all necessary modules for a customized selenium webdriver into a single class, I encountered persistent errors when implementing the code: Traceback (most recent call last): File "c:\Users\s1982& ...

Running protractor tests with headless chrome on Selenium Grid nodes is not possible

I am currently utilizing Selenium server 3.8.1 with a hub and two nodes, each running on separate machines. Although I can successfully launch tests that work properly, I am encountering issues implementing headless mode. The configuration JSON strictly ...

Selenium Webdriver: The dreaded org.openqa.selenium.NoSuchElementException strikes again

I'm encountering the following error message: org.openqa.selenium.NoSuchElementException: Unable to locate element with xpath == //*[@id='userId'] This is the HTML code I am working with: <input type="text" name="_ssoUser" id="user ...

The Flask CORS issue arises from the absence of the Access-Control-Allow-Origin header when using the redirect() function

I am currently working on setting up OAuth Twitter User-sign in using Flask API and Angular. Every time I click the sign in with Twitter button and a pop-up window opens, I encounter the following error message: XMLHttpRequest cannot load https://api.twi ...

``We can showcase API data using various endpoints and then present it on a web page using

Hello from Argentina! I'm new to programming and recently started a Flask project. I've successfully displayed information from an API using one endpoint and rendered it with Flask. However, I'm now facing the challenge of displaying informa ...

Transforming a string list into a list of numeric values

I am dealing with a list that has the following structure: mylist = ['1,2,3'] As it stands, this is a list containing one string. My goal is to transform it into a list of integers like so: mylist = [1,2,3] My attempt using [int(x) for x in m ...

Tensorflow Colab: Connection to runtime lost due to timing out

After running a model for 2 hours, a popup window appears with the message: Runtime disconnected The connection to the runtime has timed out. CLOSE RECONNECT I thought I had 12 hours to train my model after res ...

What could be causing the issue of being unable to scroll down the page with Selenium 2?

I already have gecko driver installed and I am a bit confused about why the page scroll down is not working properly. The console is not showing any errors even though I have specified that the test case should fail if a certain condition is not met: packa ...

Guide on extracting a value from Excel and integrating it into the Path

I need help with a VBA/Selenium script that will allow me to extract a value from Excel and use it in the following line of code: EdgeDr.FindElementByXPath("//table[@class='mls']//td[not(@class='nowrap')and(text()='" + Th ...

What is the method to compute the LBP codes located at the edges of the images?

Consider the example of calculating the LBP code for a pixel located at coordinates (1, 1). This calculation involves utilizing the neighboring pixels at positions (0, 0); (0, 1); (0, 2); (1, 2); (2, 2); (2, 1); (2, 0); and (1, 0). However, it is important ...

Use Python's request module to send a message to Telegram via API

I attempted to send a message to Telegram using Python while running the code on Heroku. I utilized the import request library for this task. The message was successfully sent, but I encountered an issue with Heroku: Traceback (most recent call last): 202 ...

Encountering the "Element not clickable" problem with Selenium

Unable to interact with the element. The test runs smoothly on a computer, but fails when run on a laptop displaying error message 'Element not clickable'. Attempted various wait times without success. Uncertain of the root cause. My current appr ...

The PHP exec() function is malfunctioning on the Raspberry Pi's Apache server

My Raspberry Pi is equipped with an Apache server running PHP5. I have obtained a code to manage my relay module, but the issue arises when PHP fails to execute the Python script. Here's the provided code snippet: <html> <head> <meta ...

I have several SpaCy document objects that I need to merge into a single comprehensive document object

Attempting to tokenize a text file of the King James Bible resulted in a memory error. To address this issue, the text has been divided into multiple objects for processing with spaCy. The question now arises whether combining these tokenized objects back ...

Repairing Data Formats in Data Collection

By utilizing unicodecsv.DictReader, I successfully imported a file which resulted in a list of data. import unicodecsv def read_csv(filename): with open(filename, 'rb') as f: reader = unicodecsv.DictReader(f) return list(read ...

How can I develop a REST API in Python that utilizes JSON?

As a newcomer to Python REST API, I am encountering some specific issues. My goal is to retrieve the data associated with a particular key (pathlabid) when it is entered as input. However, upon running the code below, I am only able to fetch data from th ...

Explore additional pages using Selenium with Python by clicking below

Issue I am trying to access the profiles of all the top users on this page using Selenium. The profiles of the top users can be found on the right side of the page. Steps Taken self.driver.get(response.url) user_list = self.driver.find_elements_b ...

Python 2 code for printing the diagonal from the upper right to the lower left of a matrix

I'm facing a coding challenge and feeling quite puzzled. The task at hand is to generate an empty diagonal list that displays numbers from a matrix starting from the top-right corner and going down to the bottom-left, resulting in [5, 9, 13, 17, 21]. ...

What could be causing render_template to fail when attempting to update the same parameters more than once?

Lately, I've dived into the world of Flask, MongoDB, and ElasticSearch. So far, my MongoDB and ElasticSearch setups are running smoothly. However, I've encountered an issue with generating a list of dictionaries and displaying them on my HTML we ...