Python Forum
want to make auto login with data - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: want to make auto login with data (/thread-29589.html)



want to make auto login with data - R3born - Sep-11-2020

hi i made script with selenium for auto login but i want to get data from .txt file can u help me?
format is user:pass or mail:pass


want to make auto login with data - R3born - Sep-11-2020

hi i made script with selenium for auto login but i want to get data from .txt file . format is user:pass or mail:pass

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
import time
browser = webdriver.Chrome()




browser.get("site")

browser.find_element_by_id("login-username").send_keys(email)
browser.find_element_by_id("login-password").send_keys(pass)
browser.find_element_by_id("login-button").click()

time.sleep(5)

browser.find_element_by_css_selector("._95e9f2bdfb-scss > button:nth-child(1)").click()


also i did this for get data

filepath = "combofile" 
combo = open(filepath,"r")  
line = list(filepath)    
for line in combo :        
    temp = line.strip().split(":") or both
    email = temp[0]       
    password = temp[1]   
but didnt work, with this method using all emails/passwords in one request


RE: want to make auto login with data - wintenrod - Sep-11-2020

Hello R3born

Please use the login code inside the for loop
Hence, your final code should look like this.
browser.get("site")
filepath = "combofile" 
combo = open(filepath,"r")  
line = list(filepath)    
for line in combo :        
    temp = line.strip().split(":") or both
    email = temp[0]       
    pass = temp[1]   
    browser.find_element_by_id("login-username").send_keys(email)
    browser.find_element_by_id("login-password").send_keys(pass)
    browser.find_element_by_id("login-button").click()
    time.sleep(5)
    browser.find_element_by_css_selector("._95e9f2bdfb-scss > button:nth-child(1)").click()



RE: want to make auto login with data - R3born - Sep-11-2020

(Sep-11-2020, 11:43 AM)wintenrod Wrote: Hello R3born

Please use the login code inside the for loop
Hence, your final code should look like this.
browser.get("site")
filepath = "combofile" 
combo = open(filepath,"r")  
line = list(filepath)    
for line in combo :        
    temp = line.strip().split(":") or both
    email = temp[0]       
    pass = temp[1]   
    browser.find_element_by_id("login-username").send_keys(email)
    browser.find_element_by_id("login-password").send_keys(pass)
    browser.find_element_by_id("login-button").click()
    time.sleep(5)
    browser.find_element_by_css_selector("._95e9f2bdfb-scss > button:nth-child(1)").click()

thanks!
my last question is how can i open new tab with new user:pass data?