How to use test_boilerplate method in SeleniumBase

Best Python code snippet using SeleniumBase

runner.py

Source:runner.py Github

copy

Full Screen

1#!/usr/bin/env python32"""Module for running integration tests inside of a remote cluster3Note: ssh_user must be able to use docker without sudo priveleges4"""5import logging6import sys7from os.path import join8from subprocess import CalledProcessError9from pkgpanda.util import write_string10LOGGING_FORMAT = '[%(asctime)s|%(name)s|%(levelname)s]: %(message)s'11logging.basicConfig(format=LOGGING_FORMAT, level=logging.INFO)12log = logging.getLogger(__name__)13def integration_test(14 tunnel, test_dir,15 dcos_dns, master_list, agent_list, public_agent_list,16 provider,17 test_dns_search=True,18 aws_access_key_id='', aws_secret_access_key='', region='', add_env=None,19 pytest_cmd='py.test -vv -s -rs'):20 """Runs integration test on host21 Args:22 test_dir: directory to leave test_wrapper.sh23 dcos_dns: string representing IP of DCOS DNS host24 master_list: string of comma separated master addresses25 agent_list: string of comma separated agent addresses26 test_dns_search: if set to True, test for deployed mesos DNS app27 provider: (str) either onprem, aws, or azure28 Optional args:29 aws_access_key_id: needed for REXRAY tests30 aws_secret_access_key: needed for REXRAY tests31 region: string indicating AWS region in which cluster is running32 add_env: a python dict with any number of key=value assignments to be passed to33 the test environment34 pytest_cmd: string representing command for py.test35 Returns:36 exit code corresponding to test_cmd run37 """38 dns_search = 'true' if test_dns_search else 'false'39 test_env = [40 'DCOS_DNS_ADDRESS=http://' + dcos_dns,41 'MASTER_HOSTS=' + ','.join(master_list),42 'PUBLIC_MASTER_HOSTS=' + ','.join(master_list),43 'SLAVE_HOSTS=' + ','.join(agent_list),44 'PUBLIC_SLAVE_HOSTS=' + ','.join(public_agent_list),45 'DCOS_PROVIDER=' + provider,46 'DNS_SEARCH=' + dns_search,47 'AWS_ACCESS_KEY_ID=' + aws_access_key_id,48 'AWS_SECRET_ACCESS_KEY=' + aws_secret_access_key,49 'AWS_REGION=' + region]50 if add_env:51 for key, value in add_env.items():52 extra_env = key + '=' + value53 test_env.append(extra_env)54 test_env_str = ''.join(['export ' + e + '\n' for e in test_env])55 test_boilerplate = """#!/bin/bash56{env}57cd /opt/mesosphere/active/dcos-integration-test58/opt/mesosphere/bin/dcos-shell {cmd}59"""60 write_string('test_preflight.sh', test_boilerplate.format(61 env=test_env_str, cmd='py.test -rs -vv --collect-only'))62 write_string('test_wrapper.sh', test_boilerplate.format(63 env=test_env_str, cmd=pytest_cmd))64 pretest_path = join(test_dir, 'test_preflight.sh')65 log.info('Running integration test setup check...')66 tunnel.write_to_remote('test_preflight.sh', pretest_path)67 tunnel.remote_cmd(['bash', pretest_path], stdout=sys.stdout.buffer)68 wrapper_path = join(test_dir, 'test_wrapper.sh')69 log.info('Running integration test...')70 tunnel.write_to_remote('test_wrapper.sh', wrapper_path)71 try:72 tunnel.remote_cmd(['bash', wrapper_path], stdout=sys.stdout.buffer)73 except CalledProcessError as e:74 return e.returncode...

Full Screen

Full Screen

test_boilerplate.py

Source:test_boilerplate.py Github

copy

Full Screen

...6from page_objects.PageFactory import PageFactory7from utils.Option_Parser import Option_Parser8import pytest9@pytest.mark.GUI10def test_boilerplate(test_obj):11 "Run the test"12 try:13 #Initalize flags for tests summary14 expected_pass = 015 actual_pass = -116 #This is the test object, you can change it to the desired page with relevance to the page factory17 test_obj = PageFactory.get_page_object("main page")18 #Print out the result19 test_obj.write_test_summary()20 expected_pass = test_obj.result_counter21 actual_pass = test_obj.pass_counter22 except Exception as e:23 print("Exception when trying to run test: %s"%__file__)24 print("Python says:%s"%str(e))25 assert expected_pass == actual_pass, "Test failed: %s"%__file__26#---START OF SCRIPT27if __name__=='__main__':28 print("Start of %s"%__file__)29 #Creating an instance of the class30 options_obj = Option_Parser()31 options = options_obj.get_options()32 #Run the test only if the options provided are valid33 if options_obj.check_options(options):34 test_obj = PageFactory.get_page_object("Zero",base_url=options.url)35 #Setup and register a driver36 test_obj.register_driver(options.remote_flag,options.os_name,options.os_version,options.browser,options.browser_version,options.remote_project_name,options.remote_build_name)37 test_boilerplate(test_obj)38 #teardowm39 test_obj.wait(3)40 test_obj.teardown()41 else:42 print('ERROR: Received incorrect comand line input arguments')...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

1#!/usr/bin/env python32import os, re3test_boilerplate = u"""require("AutoTouchPlus")4assert(is(exe('dpkg-query -W curl')),5 'cURL not installed. Either install it or remove this check from tests.lua (2-3)')6"""7test_files = ['tests/' + i for i in sorted(os.listdir('tests')) if i != 'test_test.lua']8data = ''9for fn in test_files:10 data += '\n\n\n'11 with open(fn) as f:12 for line in f:13 if not line.startswith('require') and not line.startswith('run_tests()'):14 data += line15 data += '\n\n\n'16data += '\nif run_tests() == 0 then (alert or print)("All tests passed!") end \n'17with open('tests/test_test.lua') as f:18 data += '\n\n\n' + '\n'.join(f.read().splitlines()[1:]) + '\n\n\n'19with open('tests.lua', 'w') as f:20 f.write(test_boilerplate)21 f.write(data)22os.system('python3 .scripts/compile.py')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful