Python Forum

Full Version: Selenium Random Elements Id and class
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been trying to extract data using selenium from a website that I have an id:
https://login.systemxlite.com/

But the problem is that every time I refresh the page. it shows up new element id and class name, how do I extract data from such websites?

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
import time
import requests

browser = webdriver.Chrome()
url = 'https://login.systemxlite.com/'
browser.get(url)
input_username = browser.find_element_by_class_name("input _1Y8XGj9ENGBa-Ik7Bcb8Lb")
input_username.send_keys('@gmail.com')
input_username.send_keys(Keys.RETURN)
input_pass = browser.find_element_by_class_name("text-input required  _1KA9k-sgH-_43Niwayzyxm LbnuI5kKQX1mPuG5AszFO")
input_pass.send_keys('xxxxx')
inputpass.send_keys(Keys.RETURN)
inputElement=browser.find_element_by_class_name('button _3CaodLH2MHcC-s3TXsSzoY button-primary _2YLlc1kIUzVCgwVOIxC2QJ')
inputElement.click()
There are few differnet ways to still obtain select an element. You could use the absoute xpath value as you do not need any attributes. Or you can use the tagname since that one page has so little.

browser = webdriver.Chrome()
url = 'https://login.systemxlite.com/'
browser.get(url)

inputs = browser.find_elements_by_tag_name('input')

inputs[0].send_keys('[email protected]')
inputs[1].send_keys('1234')