def create_location(): h = HomePage('Location') body = '{}\n'.format(make_lines(3)) body += '{}\n'.format(head(bold('Paul Scherrer Institut (PSI)'))) body += make_figure(join('figures', 'PSIAir.jpg'), 'PSI-Air', width=1200) h.set_body(indent(body, 2)) h.create()
def create_years(self): for year in self.HomePage.get_years(): if year.isdigit(): h = HomePage(year) table = YearTable(year) h.set_body(table.get_body()) h.create()
def open_browser_to_english_home_page(self): se = wrapper().connect("127.0.0.1", "4444", "*firefox", "http://www.workopolis.com") se.start() se.window_maximize() h = HomePage() h.open_english_home_page()
def test_register_valid(self): # Navigate to register self.driver.find_element_by_class_name("login").click() # textbox input self.driver.find_element_by_id("email_create").send_keys( config.CUSTOMER_EMAIL) self.driver.find_element_by_id("SubmitCreate").click() time.sleep(3) driver = self.driver # Instance of class RegisterPages register = RegisterPages(driver) register.enter_firstname(config.CUSTOMER_FIRSTNAME) register.enter_lastname(config.CUSTOMER_LASTNAME) register.enter_password(config.CUSTOMER_PASSWORD) register.enter_fsname(config.CUSTOMER_FIRSTNAME) register.enter_lname(config.CUSTOMER_LASTNAME) register.enter_company(config.CUSTOMER_COMPANY) register.enter_address1(config.CUSTOMER_COMPANY) register.enter_address2(config.CUSTOMER_ADDRESS2) register.enter_city(config.CUSTOMER_CITY) register.enter_postcode(config.CUSTOMER_POSTCODE) register.enter_information(config.CUSTOMER_INFOR) register.enter_phone(config.CUSTOMER_PHONE) register.enter_phone_mobile(config.CUSTOMER_PHONE_MOBILE) register.enter_alias(config.CUSTOMER_ALIAS) register.enter_gender() # working with selectbox state self.selectbox_state = self.driver.find_element_by_id( "id_state") # choose selexbox with id = id_state self.drp_state = Select(self.selectbox_state) # dropdown self.drp_state.select_by_index(4) self.number_options_state = len(self.drp_state.options) print("number of state oftions is : ", self.number_options_state) for i in range(self.number_options_state): self.selectbox_state = self.driver.find_element_by_id("id_state") self.drp_state = Select(self.selectbox_state) # dropdown self.drp_state.select_by_index(i) # Price highest # Working with day month year select self.days = self.driver.find_element_by_id("days") self.day_select = Select(self.days) self.day_select.select_by_index(1) self.months = self.driver.find_element_by_id("months") self.months_select = Select(self.months) self.months_select.select_by_index(1) self.years = self.driver.find_element_by_id("years") self.years_select = Select(self.years) self.years_select.select_by_index(20) register.check_invalid_firstname() #submit form homepage = HomePage(driver) homepage.register() time.sleep(5) #homepage.sign_out() print("test complete!")
def create_boards(self): h = HomePage('AmpBoards') body = '{}\n'.format(make_lines(3)) body += '{}\n'.format(head(bold('Diamond Amplifier Boards'))) rows = sorted([[center_txt(nr), option] for option in self.Config.options('Boards') for nr in loads(self.Config.get('Boards', option))]) body += add_bkg(HTMLTable.table(rows, header_row=['Nr', 'Pulser Type'], ), self.BkgCol) h.set_body(body) h.create()
def create_home(): h = HomePage('HomePage') body = '{}\n'.format(make_lines(3)) body += '{}\n'.format(head(bold('Complete Set of Data Taken at Beam Tests at PSI ...'))) body += ' <script type="text/javascript">\n' body += ' load_home();\n' body += ' </script>\n' h.set_body(indent(body, 2)) h.create()
def test_navigation(self): driver = self.driver # shortcut homepage_navigation = HomePage(driver) homepage_navigation.click_tab() homepage_navigation.wait() homepage_navigation.click_product() productpage_navigation = ProductPage(driver) productpage_navigation.wait() productpage_navigation.enter_quantity() productpage_navigation.pick_color() productpage_navigation.select_size() productpage_navigation.click_submit() productpage_navigation.wait_2() productpage_navigation.click_checkout() checkout_page = CheckOut(driver) checkout_page.wait() checkout_page.click_checkout() checkout_page.wait_2() checkout_page.enter_email() checkout_page.enter_passwd() checkout_page.click_submit() self.driver.get_screenshot_as_file( "/Users/Abraham/Pictures/googleshot.png") print(self.driver.title)
def submit(self): one = str(self.passwordr.get()) two = str(self.password2.get()) if one == two: if tkinter.messagebox.askyesno( "Register", "Are you sure you want to register this account"): username = str((self.usernamer.get()).lower()) password = str((self.passwordr.get()).lower()) time = str(datetime.now().strftime("%d-%m-%Y %H:%M:%S")) connection = sqlite3.connect("data.db") cursor = connection.cursor() cursor.execute("INSERT INTO users VALUES(NULL, ?, ?, ?)", (username, password, time)) connection.commit() connection.close() tkinter.messagebox.showinfo("Success", "Registration Successful!") result = self.fetchdata(username) self.destroy() HomePage(self.reg, *result) else: tkinter.messagebox.showinfo( "Incorrect" "The two passwords did not match, please enter matching passwords" ) pass
def __init__(self): self.Dir = dirname(realpath(__file__)) self.HomePage = HomePage(filename='default') self.Config = self.HomePage.Config self.BkgCol = 'lightgrey' # TODO FIX self.Diamond = None # in string format! Aug16 self.TestCampaign = None
def login(self, user, password): from mainpage import MainPage from homepage import HomePage box = TextBox(self._browser, self._config.get_locator('username')) box.set_text(user) box.set_locator(self._config.get_locator('password')) box.set_text(password) elem = Element(self._browser, self._config.get_locator('submit')) elem.click() page = HomePage(self._browser, False) if not page.is_logged_in(): msg = "Login failed" box.set_locator(self._config.get_locator('err_msg')) if (box.exists()): msg = box.get_text() assert msg == '' return MainPage(self._browser, False)
def login(self, user, password): from mainpage import MainPage from homepage import HomePage box = TextBox(self._browser, self._config.get_locator("username")) box.set_text(user) box.set_locator(self._config.get_locator("password")) box.set_text(password) elem = Element(self._browser, self._config.get_locator("submit")) elem.click() page = HomePage(self._browser, False) if not page.is_logged_in(): msg = "Login failed" box.set_locator(self._config.get_locator("err_msg")) if box.exists(): msg = box.get_text() assert msg == "" return MainPage(self._browser, False)
def create_full_runplans(self): table = RunPlanTable() print_banner('CREATING FULL RUNPLAN TABLES') test_campaigns = [str_to_tc(tc) for tc in table.TestCampaigns if tc == self.TestCampaign or self.TestCampaign is None] for tc in test_campaigns: h = HomePage() h.set_file_path(join('BeamTests', tc_to_str(tc), 'RunPlans.html')) h.set_body(table.get_tc_body(tc)) h.create()
def create_runs(dia_scans): table = RunTable() dia = dia_scans[0].Diamond dias = table.Diamonds print_banner('CREATING RUN TABLES FOR {} ({}/{}) in {}'.format(dia, dias.index(dia), len(dias), tc_to_str(dia_scans[0].TestCampaign, short=False))) for dia_scan in dia_scans: if dia_scan.TestCampaign < '201508': continue h = HomePage() h.set_file_path(join(dia_scan.Path, 'index.html')) h.set_body(table.get_body(dia_scan)) h.create()
def testSearchForProduct(self): print("test01_homepage") homepage = HomePage(self.driver) print("start search") search_results = homepage.search.searchFor('earphones') print("1st_assertEqual") self.assertEqual(2, search_results.product_count) print("open product page") product = search_results.open_product_page( 'MADISON OVEREAR HEADPHONES') print("2nd_assertEqual") self.assertEqual('MADISON OVEREAR HEADPHONES', product.name) self.assertEqual('$125.00', product.price) self.assertEqual('IN STOCK', product.stock_status)
def test_logout(self): try: driver = self.driver homepage = HomePage(driver) homepage.click_welcome() homepage.click_logout() x = driver.title assert x == "OrangeHRM" except: print("Some Exception Happened")
def create_dias(self): if self.TestCampaign is not None: return table = DiaTable() print_banner('CREATING SINGLE DIAMOND TABLES') diamonds = [dia for dia in table.Diamonds if dia == self.Diamond or self.Diamond is None] table.start_pbar(len(diamonds)) for i, dia in enumerate(diamonds, 1): dia_scans = table.DiaScans.get_diamond_scans(dia) h = HomePage() h.set_file_path(join('Diamonds', dia, 'index.html')) h.set_body(table.get_body(dia_scans)) h.create() table.ProgressBar.update(i) table.ProgressBar.finish()
def create_dia_runplans(self): table = RunPlanTable() print_banner('CREATING DIAMOND RUNPLAN TABLES') diamonds = [dia for dia in table.Diamonds if dia == self.Diamond or self.Diamond is None] test_campaigns = [str_to_tc(tc) for tc in table.TestCampaigns if tc == self.TestCampaign or self.TestCampaign is None] for dia in diamonds: for tc in test_campaigns: dia_scans = table.DiaScans.get_tc_diamond_scans(dia, tc) if not dia_scans: continue # continue if the diamond was not measured during this campaign h = HomePage() h.set_file_path(join(dirname(dia_scans[0].Path), 'index.html')) h.set_body(table.get_dia_body(dia_scans)) h.create() self.create_runs(dia_scans) self.create_picture_pages(dia_scans)
def __init__(self): Instances.MainWindow = self font = QApplication.instance().font() rc('font', **{'family': 'serif', 'serif': [font.defaultFamily()]}) super(PySpectrumMainWindow, self).__init__() self.ui = Ui_PySpectrumMainWindow() self.database = sqlite3.connect(os.path.join('data', 'pyspectrum.db')) self.ui.setupUi(self) self.settings = QSettings("GuLinux", "PySpectrum") self.homepage = HomePage(self.settings, self.database) self.ui.stackedWidget.addWidget(self.homepage) self.windows_menu = QtCommons.addToolbarPopup( self.ui.toolBar, 'Windows', icon_file=':/bullet_list_20') self.actionClose = self.ui.toolBar.addAction(QIcon(':/close_20'), "Close") self.actionClose.setEnabled(False) self.actionClose.triggered.connect(self.close_widget) self.homepage.import_image.connect(self.open_image) self.homepage.calibrate.connect(self.calibrate) self.homepage.math.connect(self.plots_math) self.homepage.finish.connect(self.finish_spectrum) self.homepage.new_project.connect(self.__new_project) self.homepage.stack_images.connect(self.__stack_images) self.homepage.open_project.connect(self.__open_project) self.ui.stackedWidget.currentChanged.connect(self.current_changed) self.current_widget_toolbar = None self.restoreGeometry( self.settings.value('window_geometry', QByteArray())) self.widgets = [(self.homepage, "Home")] self.current_changed(self.ui.stackedWidget.indexOf(self.homepage)) def action_checked(actions, action): for a in actions: a.setChecked(a == action) self.windows_menu.menu().triggered.connect( lambda a: action_checked(self.windows_menu.menu().actions(), a)) self.__rebuild_windows_menu()
def scenario_GALC(self, dataset): homePage = HomePage(self.driver) webDemo = homePage.selectDemoApp('GALC') webDemo.setDataSet(dataset) webDemo.processData()
def test_browseLink(self): h = HomePage(self.driver) h.goToBrowseArchive()
while is_true: while login_window.sign_up: sign_up_window = SignUp() if not sign_up_window.is_closed: username = sign_up_window.username password = sign_up_window.password connection = database.connect() database.add_user(connection, username, password) login_window = LogIn() if login_window.is_closed: is_true = False if login_window.create_homepage: homepage_window = HomePage(login_window.table_name) while not homepage_window.is_closed: if homepage_window.expense: expense_window = Expense(login_window.table_name) homepage_window = HomePage(login_window.table_name) if homepage_window.income: income_window = Income(login_window.table_name) homepage_window = HomePage(login_window.table_name) if homepage_window.transaction: transaction_window = Transaction(login_window.table_name) homepage_window = HomePage(login_window.table_name) if homepage_window.delete: delete_window = Delete(login_window.table_name) homepage_window = HomePage(login_window.table_name) if homepage_window.analysis: analysis_window = Analysis(login_window.table_name)
def scenario_GAL(self, algorithm, dataset): homePage = HomePage(self.driver) webDemo = homePage.selectDemoApp('GAL') webDemo.setAlgorithm(algorithm) webDemo.setDataSet(dataset) webDemo.processData()
class HomePageTest(unittest.TestCase): @classmethod def setUpClass(self): self.dr = my_driver() self.hp = HomePage(self.dr) self.hp.open() self.hp.layerclose() #新浪微博 # def test1_websina(self): # self.hp.websina() # time.sleep(3) # text1 = self.dr.current_url # self.assertIn('https://weibo.com/apengdai', text1) # self.dr.close() def test2_weqq(self): """页面顶部QQ群不为空""" self.hp.open() text2 = self.hp.weqq() self.assertIsNotNone(text2, '页面顶部qq群此处为空') #msg此处为fail时打印的信息 def test3_wechat(self): """页面顶部微信公众号不为空""" self.hp.open() text3 = self.hp.wechat() self.assertIsNotNone(text3, '页面顶部微信公众号不为空') def test4_borrow_right_head(self): """我要借款""" self.hp.borrow_right_head() time.sleep(3) text4 = self.dr.current_url self.dr.back() text = "/" + text4.split('/', 3)[3] #获取url后缀路径 print(text) self.assertEqual(text, '/lend/index') def test5_helpcenter(self): """页面顶部帮助中心""" self.hp.helpcenter() time.sleep(3) text5 = self.dr.current_url text = "/" + text5.split('/', 3)[3] self.assertEqual(text, '/help/js') #获取帮助中心路径 #self.dr.back() def test6_lend_link(self): """导航栏-我要出借""" self.hp.open() self.hp.lend_link() text6 = self.dr.current_url text = "/" + text6.split('/', 3)[3] #获取我要出借路径 self.assertEqual(text, '/licai/') def test7_information_link(self): """导航栏-信息披露""" self.hp.information_link() text7 = self.dr.current_url text = "/" + text7.split('/', 3)[3] #获取信息披露路径 self.assertEqual(text, '/information/safeController') def test8_riskedc_link(self): """导航栏-风险教育""" self.hp.riskedc_link() text8 = self.dr.current_url text = "/" + text8.split('/', 3)[3] #获取风险教育路径 self.assertEqual(text, '/risktip/fxjy') def test9_aboutUs_link(self): """导航栏-关于我们""" self.hp.aboutUs_link() text9 = self.dr.current_url text = "/" + text9.split('/', 3)[3] #获取关于我们路径 self.assertEqual(text, '/information/informationPublic') def test10_invitefriends(self): """邀请好友""" self.hp.open() self.hp.invitefriends() text10 = self.dr.current_url self.dr.back() text = "/" + text10.split('/', 3)[3] #获取邀请好友路径 self.assertEqual(text, '/special/invitefriends') def test11_transfer(self): """转让专区""" self.hp.transfer() text11 = self.dr.current_url print("text11=" + text11) self.dr.back() print("转让=" + self.dr.current_url) text = "/" + text11.split('/', 3)[3] #获取转让专区路径 self.assertEqual(text, '/creditAssignList/list-0-0-0-1') def test12_activities(self): """活动专区""" self.hp.activities() text12 = self.dr.current_url text = "/" + text12.split('/', 3)[3] #获取活动专区路径 self.assertEqual(text, '/help/activity?status=1') def test13_exchange(self): """兑换专区""" self.hp.open() self.hp.exchange() text13 = self.dr.current_url self.dr.back() text = "/" + text13.split('/', 3)[3] #获取兑换专区路径 self.assertEqual(text, '/pointsshop/goodsList') def test14_Newbie(self): """新手专区""" self.hp.Newbie() text14 = self.dr.current_url text = "/" + text14.split('/', 3)[3] #获取新手专区路径 self.assertEqual(text, '/special/newGuide') def test15_accumulated_amount(self): """累计交易额不为0""" self.hp.open() time.sleep(3) text15 = self.hp.accumulated_amount() self.assertGreaterEqual(text15, 1892907) def test16_accumulated_number(self): """累计注册人数大于等于当前""" text16 = self.hp.accumulated_number() self.assertGreaterEqual(text16, 9072) @classmethod def tearDownClass(self): self.dr.quit()
def setUpClass(self): self.dr = my_driver() self.hp = HomePage(self.dr) self.hp.open() self.hp.layerclose()
def enter_goods_page(self): '''进入商品模块''' home_page = HomePage(self.driver) home_page.click_goods()
def create_old(): h = HomePage('Old') table = OldTable() h.set_body(table.get_body()) h.create()
def indexPage(): return HomePage().fetchHomePage(helper)
def test_title(self): h = HomePage(self.driver) print "got here" h.waitPageLoad("Ontario Independent Music Archive") assert h.getExpectedPageName() == "Ontario Independent Music Archive"
class Website: def __init__(self): self.Dir = dirname(realpath(__file__)) self.HomePage = HomePage(filename='default') self.Config = self.HomePage.Config self.BkgCol = 'lightgrey' # TODO FIX self.Diamond = None # in string format! Aug16 self.TestCampaign = None def update_run_plans(self): cmd = 'rsync -aP mutter:/home/reichmann/software/RatePadAnalysis/Runinfos/run_plans.json {}'.format(join(self.Dir, 'data')) system(cmd) def update_irradiation_file(self): cmd = 'rsync -aP mutter:/home/reichmann/software/RatePadAnalysis/Runinfos/irradiation.json {}'.format(join(self.Dir, 'data')) system(cmd) def update_diamond_aliases(self): cmd = 'rsync -aP mutter:/home/reichmann/software/RatePadAnalysis/Configuration/DiamondAliases.cfg {}'.format(join(self.Dir, 'data')) system(cmd) def update_masks(self): cmd = 'rsync -aP mutter:/scratch2/psi/psi*/masks/*.msk {}'.format(join(self.Dir, 'masks')) system(cmd) def update_run_log(self, tc): psi_dir = 'psi_{}_{}'.format(tc[:4], tc[4:]) cmd = 'rsync -aP mutter:/scratch2/psi/{}/run_log.json {}'.format(psi_dir, join(self.Dir, 'data', 'run_log{}.json'.format(tc))) system(cmd) def update_run_logs(self): for tc in self.HomePage.get_testcampaigns(): if tc > '201505': self.update_run_log(tc) def update(self): self.update_run_plans() self.update_irradiation_file() self.update_diamond_aliases() self.update_masks() self.update_run_logs() @staticmethod def create_home(): h = HomePage('HomePage') body = '{}\n'.format(make_lines(3)) body += '{}\n'.format(head(bold('Complete Set of Data Taken at Beam Tests at PSI ...'))) body += ' <script type="text/javascript">\n' body += ' load_home();\n' body += ' </script>\n' h.set_body(indent(body, 2)) h.create() @staticmethod def create_location(): h = HomePage('Location') body = '{}\n'.format(make_lines(3)) body += '{}\n'.format(head(bold('Paul Scherrer Institut (PSI)'))) body += make_figure(join('figures', 'PSIAir.jpg'), 'PSI-Air', width=1200) h.set_body(indent(body, 2)) h.create() def create_boards(self): h = HomePage('AmpBoards') body = '{}\n'.format(make_lines(3)) body += '{}\n'.format(head(bold('Diamond Amplifier Boards'))) rows = sorted([[center_txt(nr), option] for option in self.Config.options('Boards') for nr in loads(self.Config.get('Boards', option))]) body += add_bkg(HTMLTable.table(rows, header_row=['Nr', 'Pulser Type'], ), self.BkgCol) h.set_body(body) h.create() @staticmethod def create_old(): h = HomePage('Old') table = OldTable() h.set_body(table.get_body()) h.create() def create_years(self): for year in self.HomePage.get_years(): if year.isdigit(): h = HomePage(year) table = YearTable(year) h.set_body(table.get_body()) h.create() def create_dia_runplans(self): table = RunPlanTable() print_banner('CREATING DIAMOND RUNPLAN TABLES') diamonds = [dia for dia in table.Diamonds if dia == self.Diamond or self.Diamond is None] test_campaigns = [str_to_tc(tc) for tc in table.TestCampaigns if tc == self.TestCampaign or self.TestCampaign is None] for dia in diamonds: for tc in test_campaigns: dia_scans = table.DiaScans.get_tc_diamond_scans(dia, tc) if not dia_scans: continue # continue if the diamond was not measured during this campaign h = HomePage() h.set_file_path(join(dirname(dia_scans[0].Path), 'index.html')) h.set_body(table.get_dia_body(dia_scans)) h.create() self.create_runs(dia_scans) self.create_picture_pages(dia_scans) def create_dias(self): if self.TestCampaign is not None: return table = DiaTable() print_banner('CREATING SINGLE DIAMOND TABLES') diamonds = [dia for dia in table.Diamonds if dia == self.Diamond or self.Diamond is None] table.start_pbar(len(diamonds)) for i, dia in enumerate(diamonds, 1): dia_scans = table.DiaScans.get_diamond_scans(dia) h = HomePage() h.set_file_path(join('Diamonds', dia, 'index.html')) h.set_body(table.get_body(dia_scans)) h.create() table.ProgressBar.update(i) table.ProgressBar.finish() @staticmethod def create_picture_pages(dia_scans): for dia_scan in dia_scans: page = PicturePage(dia_scan) page.make() @staticmethod def create_runs(dia_scans): table = RunTable() dia = dia_scans[0].Diamond dias = table.Diamonds print_banner('CREATING RUN TABLES FOR {} ({}/{}) in {}'.format(dia, dias.index(dia), len(dias), tc_to_str(dia_scans[0].TestCampaign, short=False))) for dia_scan in dia_scans: if dia_scan.TestCampaign < '201508': continue h = HomePage() h.set_file_path(join(dia_scan.Path, 'index.html')) h.set_body(table.get_body(dia_scan)) h.create() def create_full_runs(self): table = RunTable() print_banner('CREATING FULL RUN TABLES') test_campaigns = [str_to_tc(tc) for tc in table.TestCampaigns if tc == self.TestCampaign or self.TestCampaign is None] for tc in test_campaigns: h = HomePage() h.set_file_path(join('BeamTests', tc_to_str(tc), 'index.html')) h.set_body(table.get_tc_body(tc)) h.create() def create_full_runplans(self): table = RunPlanTable() print_banner('CREATING FULL RUNPLAN TABLES') test_campaigns = [str_to_tc(tc) for tc in table.TestCampaigns if tc == self.TestCampaign or self.TestCampaign is None] for tc in test_campaigns: h = HomePage() h.set_file_path(join('BeamTests', tc_to_str(tc), 'RunPlans.html')) h.set_body(table.get_tc_body(tc)) h.create() def build(self): t = time() self.create_home() self.create_location() self.create_old() self.create_years() self.create_boards() self.create_dia_runplans() self.create_dias() self.create_full_runs() self.create_full_runplans() print 'This took {}'.format(time() - t)
def enter_coupon_menu(self): '''进入营销模块''' home_page=HomePage(self.driver) home_page.click_marketing()
def __init__(self, dia_scan, config='conf.ini'): HomePage.__init__(self, 'pic_test', config) self.DiaScan = dia_scan self.Body = ''
def setUpClass(cls): cls.driver = webdriver.Chrome() login = Login(cls.driver) cls.home_page = HomePage(cls.driver) cls.order_page = OrderPage(cls.driver) login.login()
def testSearchCaseTest(self): keyword = u"大明宫中央广场" homepage = HomePage(self.driver) search_case = SearchRegion(self.driver) searchResults = search_case.searchFor(keyword) self.assertEqual(keyword, searchResults.resultKey)
def enter_orer_menu(self): '进入订单模块' ORDERMENU_LOC = HomePage(self.driver).ORDERS_LOC self.click(ORDERMENU_LOC)