Skip to content

Instantly share code, notes, and snippets.

@wehappyfew
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wehappyfew/7e3ea053d255f7638130 to your computer and use it in GitHub Desktop.
Save wehappyfew/7e3ea053d255f7638130 to your computer and use it in GitHub Desktop.
import unittest
from Site import config, Login
from Site.helpers import fetch_excel_values
class Check_Excel_Logins(config.Fixtures_local):
"""
The test reads the excel ,
imports all the data in dictionaries
logs in with every username(email)/password combination
checks some stuff
logs out
"""
LIVE = True
#real data
# excel_filepath = "C:\Users\wehappyfew\Desktop\All_the_users.xlsx"
# email_pass,em_name,username_pass,up_name = fetch_excel_values(filepath=excel_filepath,sheet_index=0)
#check with these before using the real data
email_pass = { "mycreds@site.com":"123456" }
#em_name = { "" : "" }
username_pass = { "someuser@site.com":"1234567" }
#up_name = { "" : "" }
def test_1(self):
for email,password in self.email_pass.iteritems():
Login.All_Logins(self, username=email, password=password, live=self.LIVE)
# check_site(self, self.LIVE)
Login.Logout(self, self.LIVE)
for username,password in self.username_pass.iteritems():
Login.All_Logins(self, username=username, password=password, live=self.LIVE)
# check_site(self, self.LIVE)
Login.Logout(self, self.LIVE)
if __name__ == '__main__':
unittest.main()
# Customized checks for Site #
def check_site(self,live):
"""
Login and check some basic stuff
"""
success = True
wd = self.wd
if len(wd.find_elements_by_xpath("//a[contains(.,'Element1')]")) != 0 \
or len(wd.find_elements_by_xpath("//a[contains(.,'Element2')]")) != 0 \
or len(wd.find_elements_by_xpath("//a[contains(.,'Element3')]")) != 0 :
pass
else:
self.assertTrue(success)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment