fill username using selenium python for a Riot.js - login-box

124 views Asked by At

https://sso.toutiao.com/login/?next=/&service=https://mp.toutiao.com/sso_confirm/?redirect_url=/

I am trying to reach the website above and automaticlly fill username using selenium and python.

it seems like that the login box is writing in Riot.js , I just can't find the username element in html, how can I automaticlly fill username using selenium ?

I am very new to selenium and Riot.js.

any help will be appreciated.


from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import pyperclip
import sys


chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(chrome_options=chrome_options) 
browser.get("https://sso.toutiao.com/login/next=/&service=https://mp.toutiao.com/sso_confirm/?redirect_url=/")

mobile = browser.find_element_by_id("mobile")
code = browser.find_element_by_id("code")

mobile.send_keys("xxxxx")
code.send_keys("xxxx")
1

There are 1 answers

0
DeepSpace On BEST ANSWER

The username input seems to have CSS id account and xpath //*[@id="account"]. This should be enough for selenium to access it:

username_input = browser.find_element_by_xpath('//*[@id="account"]')
username_input.send_keys('username')