Selenium Python Discord Interaction

Viewed 82

Hi I'm having issues with the below code. The issue is once I've opened a sub menu and try and send down arrow as keys it wont work, the only time the keys get sent is when I send a ridiculous multiplier like *100. Any help would be 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
1 Answers

This is what I would do in python,

instead of this line :

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

you can try the below code :

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