python - Loading lines with Selenium -
in python 2.7, using selenium, want script open 'masters.txt' file. then, go twitter (while logged in beforehand), , post line so:
driver.get("https://twitter.com") elem = driver.find_element_by_name('tweet') elem.send_keys(line1 + " #worked") elem = driver.find_element_by_xpath('//*[@id="timeline"]/div[2]/div/form/div[2]/div[2]/button') elem.send_keys(keys.return)
then, same, except:
elem.send_keys(line2 + " #worked")
then, same, except:
elem.send_keys(line3 + " #worked")
etc...
so, load every single line & tweet + "with text i've added". how possible?
thanks in advance! :)
edit: example of 'master.txt' (text file) contents:
test blablabla awesome awesome tweet line
etc...
what i've tried: f = open("masters.txt") lines = f.readlines() line in lines: elem.send_keys(line + " #worked")
however doesn't work , messes etc... if complete code , write me i'm looking for, great! :)