0

I am trying to use selenium to create a new youtube channel. I am able to login, set a channel name, then click the create channel button; however, it says I am not able to create a channel. I have looked threw the code and it says that I need to have javascript enabled, which I have done. But it is still not working, any suggestions?

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--enable-javascript")
#chrome_options.add_argument("--headless")
driver = webdriver.Chrome(executable_path="chromedriver.exe", options=chrome_options)

driver.get("https://www.youtube.com/account")

emailField = driver.find_element_by_xpath("//input[@type='email']")
emailField.send_keys(email)
emailField.send_keys(Keys.RETURN)

time.sleep(1)
passwordField = driver.find_element_by_xpath("//input[@type='password']")
passwordField.send_keys(password)
passwordField.send_keys(Keys.RETURN)

time.sleep(2)
driver.find_element_by_xpath("//a[contains(text(),'Add or manage your channel(s)')]").click()
time.sleep(2)
driver.find_element_by_xpath("//a[@href='/create_channel?action_create_new_channel_redirect=true']").click()
time.sleep(2)
driver.find_element_by_xpath("//input[@id='PlusPageName']").send_keys('Test{}'.format(random.randint(1,100)))
driver.find_element_by_xpath("//input[@id='submitbutton']").click()
Maxwell Tan
  • 11
  • 1
  • 4

1 Answers1

0

It's probably becuase of youtubes bot detection, did something simlair with instagram a while ago and had to create a script that moved the mouse to some exact coordinates.

Fritiof Rusck
  • 404
  • 1
  • 3
  • 11