1
votes

I'm trying to automate twitch clip submission for good plays that he's made on cod but am having some problems.

this is a testing form that I set up which is identical to the one clips would be getting submitted to normally - https://forms.gle/MDMM3buW2DT5erpp8

from selenium import webdriver

option = webdriver.ChromeOptions()
option.add_argument("-incognito")


browser = webdriver.Chrome(executable_path='/Users/Goldilocks/Downloads/chromedriver', options=option)

browser.get("https://forms.gle/MDMM3buW2DT5erpp8")

clipDescription = "streamer sticks juggernaut with semtex for the win!"
clipLink = "https://twitch.tv/joocylad"
textboxes = browser.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
radiobuttons = browser.find_elements_by_class_name("docssharedWizToggleLabeledLabelWrapper")
submitbutton = browser.find_element_by_class_name("appsMaterialWizButtonPaperbuttonContent")


radiobuttons[3].click()

radiobuttons[2].click()

textboxes[0].send_keys("JoocyLad")

textboxes[1].send_keys(clipLink)

textboxes[2].send_keys(clipDescription)

textboxes[3].send_keys("email")


submitbutton[0].click()

browser.close()

the code isn't fully finished, I'm going to make clipLink and clipDescription into variables that take input when the program is run but I haven't gotten around to that yet.

the problem I'm having is that the second multiple choice question isn't being filled in. and I also get the error:

Traceback (most recent call last):
  File "/Users/Goldilocks/PycharmProjects/pythonProject/test.py", line 31, in <module>
    submitbutton[0].click()
TypeError: 'WebElement' object is not subscriptable

I'm on google chrome version 87.0.4280.88 and the chrome driver is the same version, 87.0.4280.88

2

2 Answers

0
votes

This error message...

TypeError: 'WebElement' object is not subscriptable

...implies that you have added an index to a WebElement which isn't subscriptable. Index can be used to access the elements of a list.


find_element_by_class_name()

find_element_by_class_name() finds an element within this element's children by class name.

As find_element_by_class_name() returns a single element it doesn't have an index and is not subscriptable.


Solution

You need to remove the index from the line submitbutton[0].click(). So your effective line of code will be:

submitbutton.click()
0
votes

I think problem is that find_element_by_class_name() returns a single item, not a list. Remove [0] and it should works. Also take a look here