I'm trying to iterate two text files. I have two text files one is for 'username' and another is for 'password'.
It works when I use functions with single argument. here's the code but not when it comes to use 2 or more than 1 argument.
Here's my code:
import os
import time
import getpass
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def Quora_bot():
username = None
password = None
chromedriver = 'F:\All Folders\chromedriver\shit.exe'
#Uncomment this block if you don't want images to load(makes the procss a little bit faster)
'''
chromeOptions = webdriver.ChromeOptions()
prefs = {"profile.managed_default_content_settings.images":2}
chromeOptions.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(chromedriver, chrome_options=chromeOptions)
'''
browser = webdriver.Chrome(chromedriver)
browser.get("http://www.quora.com") # Quora home page
time.sleep(10)
# Logging into Quora
form = browser.find_element_by_class_name('regular_login')
email = form.find_element_by_name("email")
password = form.find_element_by_name("password")
button_element = browser.find_element_by_xpath("//*[@value='Login']")
email.send_keys(username)
password.send_keys(password)
with open('newfile.txt') as u:
for line in u:
rr = line
with open('password.txt') as p:
for linee in p:
pp = linee
Quora_bot()
username = rr
password = pp
And I'm getting this error.
F:\Python_Installer\python.exe C:/Users/user/PycharmProjects/Quora_Bot/westing.py
Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/Quora_Bot/westing.py", line 45, in <module>
Quora_bot()
File "C:/Users/user/PycharmProjects/Quora_Bot/westing.py", line 32, in Quora_bot
email.send_keys(username)
File "F:\Python_Installer\lib\site-packages\selenium\webdriver\remote\webelement.py", line 348, in send_keys
{'text': "".join(keys_to_typing(value)),
File "F:\Python_Installer\lib\site-packages\selenium\webdriver\common\utils.py", line 150, in keys_to_typing
for i in range(len(val)):
TypeError: object of type 'NoneType' has no len()
Process finished with exit code 1
for, object