How to use launch_server method in Playwright Python

Best Python code snippet using playwright-python

cheat_sheet.py

Source:cheat_sheet.py Github

copy

Full Screen

...115 f"cd ..{folder_seperator}..",116 ]117 )118 activated_environment = True119 if launch_server():120 if not activated_environment:121 commands.append(activate_environment)122 commands.append(123 f".{folder_seperator}{archive}{folder_seperator}reflect"124 + (".exe" if is_win else "")125 )126 return "\n".join(line for line in commands if line is not None)127 return script128 def create_link(extension=""):129 name = f"reflect-{platform()}.{python()}-{reflect()}.tar.gz{extension}"130 return f'[{name}](download:{"/data/archives/" + name})'131 def label(content):132 return div(content, style={"textAlign": "right"})133 def create_col(content, style=None):...

Full Screen

Full Screen

server_option_parser.py

Source:server_option_parser.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3# Copyright (C) 2018 Mate Soos4#5# This program is free software; you can redistribute it and/or6# modify it under the terms of the GNU General Public License7# as published by the Free Software Foundation; version 28# of the License.9#10# This program is distributed in the hope that it will be useful,11# but WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13# GNU General Public License for more details.14#15# You should have received a copy of the GNU General Public License16# along with this program; if not, write to the Free Software17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA18# 02110-1301, USA.19import optparse20import random21import time22import string23import configparser24def parse_arguments():25 class PlainHelpFormatter(optparse.IndentedHelpFormatter):26 def format_description(self, description):27 if description:28 return description + "\n"29 else:30 return ""31 usage = """usage: %prog32To use other solvers, give:33--solver SWDiA5BY.alt.vd.res.va2.15000.looseres.3tierC5/binary/SWDiA5BY_static.alt.vd34--solver SWDiA5BY_A26/binary/SWDiA5BY_static_A2635--solver lingeling_ayv/binary/lingeling_ayv36--solver glucose2016/simp/glucose_static_201637--solver MapleCOMSPS/simp/maplecomsps_static38--solver cmsat-satcomp16/bin/cryptominisat4_simple39--solver lingeling-bbc/build/lingeling/lingeling_bbc40--solver Maple_LCM_Dist/Maple_LCM_Dist # may work with --drat, but needs updated DRAT checker41Use-cases:42# normal run43./launch_server.py --cnflist satcomp17_updated44# stats run45./launch_server.py --cnf test_updated --stats --drat --tout 600 --memlimit 1000046./launch_server.py --cnf unsat_small_candidates_fullpath --stats --drat --tout 600 --memlimit 1000047# testing, using small instance to check (cheaper & faster)48./launch_server.py --cnflist test_updated49# 2 clients, no preprocessing50./launch_server.py --cnflist satcomp14 -c 2 --opt "--preproc 0" --folder no_preproc51# gaussian elimination -- automatic detection, built with GAUSS52./launch_server.py --cnflist satcomp14 --folder gauss53# clause IDs so learning can be performed -- gzipped SQL output with clause IDs will be produced54./launch_server.py --stats --drat --folder learning55# to give options to the solver56./launch_server.py --folder with_opts --opt \"--ml=1,--keepglue=4\""57 # to upload features_to_reconf.cpp58aws s3 cp ../../src/features_to_reconf.cpp s3://msoos-solve-data/solvers/59"""60 parser = optparse.OptionParser(usage=usage, formatter=PlainHelpFormatter())61 parser.add_option("--verbose", "-v", action="store_true",62 default=False, dest="verbose", help="Be more verbose"63 )64 parser.add_option("--numclients", "-c", default=None, type=int,65 dest="client_count", help="Number of clients to launch"66 )67 parser.add_option("--port", "-p", default=10000, dest="port",68 help="Port to listen on. [default: %default]", type="int"69 )70 parser.add_option("--tout", "-t", default=3000, dest="timeout_in_secs",71 help="Timeout for the file in seconds"72 "[default: %default]",73 type=int74 )75 parser.add_option("--toutmult", default=12.1, dest="tout_mult",76 help="Approx: 1x is solving, 10x time is DRAT time wait, 1x is parsing, 0.1x that is sending us the result."77 "[default: %default]",78 type=float79 )80 parser.add_option("--memlimit", "-m", default=1600, dest="mem_limit_in_mb",81 help="Memory limit in MB"82 "[default: %default]",83 type=int84 )85 parser.add_option("--cnflist", default="satcomp14_updated", dest="cnf_list",86 type=str,87 help="The list of CNF files to solve, first line the dir"88 "[default: %default]",89 )90 parser.add_option("--dir", default="/home/ubuntu/", dest="base_dir", type=str,91 help="The home dir of cryptominisat [default: %default]"92 )93 parser.add_option("--solver",94 default="cryptominisat/build/cryptominisat5",95 dest="solver",96 help="Solver executable"97 "[default: %default]",98 type=str99 )100 parser.add_option("--folder", default="results", dest="given_folder",101 help="S3 folder name to upload data"102 "[default: %default]",103 type=str104 )105 parser.add_option("--git", dest="git_rev", type=str,106 help="The GIT revision to use. Default: HEAD"107 )108 parser.add_option("--opt", dest="extra_opts", type=str, default="",109 help="Extra options to give to solver"110 "[default: %default]",111 )112 parser.add_option("--noshutdown", "-n", default=False, dest="noshutdown",113 action="store_true", help="Do not shut down clients"114 )115 parser.add_option("--drat", default=False, dest="drat",116 action="store_true", help="Use DRAT"117 )118 parser.add_option("--stats", default=False, dest="stats",119 action="store_true", help="Use STATS and get SQLITE data"120 )121 parser.add_option("--gauss", default=False, dest="gauss",122 action="store_true", help="Use GAUSS"123 )124 parser.add_option("--logfile", dest="logfile_name", type=str,125 default="python_server_log.log", help="Name of LOG file")126 # parse options127 options, args = parser.parse_args()128 conf = configparser.ConfigParser()129 if options.cnf_list == "test":130 conf.read('ec2-spot-instance-test.cfg')131 else:132 conf.read('ec2-spot-instance.cfg')133 options.s3_bucket = conf.get("ec2", "result_bucket")134 options.key_name = conf.get("ec2", "key_name")135 options.security_group_server = conf.get("ec2", "security_group_server")136 options.subnet_id = conf.get("ec2", "subnet_id")137 options.ami_id = conf.get("ec2", "ami_id")138 options.region = conf.get("ec2", "region")139 def rnd_id():140 return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5))141 options.logfile_name = options.base_dir + options.logfile_name142 options.given_folder += "-" + time.strftime("%d-%B-%Y")143 options.given_folder += "-%s" % rnd_id()144 options.given_folder += "-%s" % options.cnf_list145 if options.drat and not options.stats:146 print("ERROR: You must have --stats when you use --drat")147 exit(-1)148 return options, args149if __name__ == "__main__":150 options, args = parse_arguments()151 print("Options are:", options)...

Full Screen

Full Screen

openvpn.py

Source:openvpn.py Github

copy

Full Screen

1#!/usr/bin/env python32# -*- coding: utf-8 -*-3# OpenBACH is a generic testbed able to control/configure multiple4# network/physical entities (under test) and collect data from them. It is5# composed of an Auditorium (HMIs), a Controller, a Collector and multiple6# Agents (one for each network entity that wants to be tested).7#8#9# Copyright © 2016-2020 CNES10#11#12# This file is part of the OpenBACH testbed.13#14#15# OpenBACH is a free software : you can redistribute it and/or modify it under16# the terms of the GNU General Public License as published by the Free Software17# Foundation, either version 3 of the License, or (at your option) any later18# version.19#20# This program is distributed in the hope that it will be useful, but WITHOUT21# ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS22# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more23# details.24#25# You should have received a copy of the GNU General Public License along with26# this program. If not, see http://www.gnu.org/licenses/.27""" Helpers of openvpn job """28from ..utils import filter_none29PROTOCOL = 'udp'30PORT = 119431SERVER_TUN_IP = '10.10.10.1'32CLIENT_TUN_IP = '10.10.10.2'33DEVICE = 'tun0'34def openvpn(35 scenario, server_entity, server_ip, client_entity, client_ip=None, no_bind_client=False,36 server_port=PORT, client_port=PORT, protocol=PROTOCOL,37 server_tun_dev=DEVICE, client_tun_dev=DEVICE,38 server_tun_ip=SERVER_TUN_IP, client_tun_ip=CLIENT_TUN_IP,39 pass_tos=False, no_security=False, tcp_nodelay=False,40 ping=0, ping_restart=-1, route_through_vpn_client=None, route_through_vpn_server=None,41 wait_finished=None, wait_launched=None, wait_delay=0):42 launch_server = scenario.add_function(43 'start_job_instance',44 wait_finished=wait_finished,45 wait_launched=wait_launched,46 wait_delay=wait_delay)47 param_server = filter_none(local_ip=server_ip,48 protocol=protocol,49 local_port=server_port,50 tun_device=server_tun_dev,51 local_tun_ip=server_tun_ip,52 remote_tun_ip=client_tun_ip,53 pass_tos=pass_tos,54 no_security=no_security,55 tcp_nodelay=tcp_nodelay,56 ping=ping,57 ping_restart=ping_restart,58 route_through_vpn=route_through_vpn_server59 )60 launch_server.configure(61 'openvpn', server_entity, offset=0,62 server={},63 **param_server)64 launch_client = scenario.add_function(65 'start_job_instance',66 wait_launched=[launch_server],67 wait_delay=2)68 param_client = filter_none(local_ip=client_ip,69 protocol=protocol,70 local_port=client_port,71 tun_device=client_tun_dev,72 local_tun_ip=client_tun_ip,73 remote_tun_ip=server_tun_ip,74 pass_tos=pass_tos,75 no_security=no_security,76 tcp_nodelay=tcp_nodelay,77 ping=ping,78 ping_restart=ping_restart,79 route_through_vpn=route_through_vpn_client80 )81 launch_client.configure(82 'openvpn', client_entity, offset=0,83 client={84 'server_ip': server_ip,85 'server_port': server_port,86 'nobind': no_bind_client,87 },88 **param_client)89 return [launch_server, launch_client]90def openvpn_behind_nat(91 scenario, server_entity, server_ip, client_entity, remote_point_ip, client_ip=None, no_bind_client=False,92 server_port=PORT, client_port=PORT, protocol=PROTOCOL,93 server_tun_dev=DEVICE, client_tun_dev=DEVICE,94 server_tun_ip=SERVER_TUN_IP, client_tun_ip=CLIENT_TUN_IP,95 pass_tos=False, no_security=False, tcp_nodelay=False,96 ping=0, ping_restart=-1, route_through_vpn_client=None, route_through_vpn_server=None,97 wait_finished=None, wait_launched=None, wait_delay=0):98 launch_server = scenario.add_function(99 'start_job_instance',100 wait_finished=wait_finished,101 wait_launched=wait_launched,102 wait_delay=wait_delay)103 param_server = filter_none(local_ip=server_ip,104 protocol=protocol,105 local_port=server_port,106 tun_device=server_tun_dev,107 local_tun_ip=server_tun_ip,108 remote_tun_ip=client_tun_ip,109 pass_tos=pass_tos,110 no_security=no_security,111 tcp_nodelay=tcp_nodelay,112 ping=ping,113 ping_restart=ping_restart,114 route_through_vpn=route_through_vpn_server115 )116 launch_server.configure(117 'openvpn', server_entity, offset=0,118 server={},119 **param_server)120 launch_client = scenario.add_function(121 'start_job_instance',122 wait_launched=[launch_server],123 wait_delay=2)124 param_client = filter_none(local_ip=client_ip,125 protocol=protocol,126 local_port=client_port,127 tun_device=client_tun_dev,128 local_tun_ip=client_tun_ip,129 remote_tun_ip=server_tun_ip,130 pass_tos=pass_tos,131 no_security=no_security,132 tcp_nodelay=tcp_nodelay,133 ping=ping,134 ping_restart=ping_restart,135 route_through_vpn=route_through_vpn_client136 )137 launch_client.configure(138 'openvpn', client_entity, offset=0,139 client={140 'server_ip': remote_point_ip,141 'server_port': server_port,142 'nobind': no_bind_client,143 },144 **param_client)...

Full Screen

Full Screen

tests.py

Source:tests.py Github

copy

Full Screen

...68sys.modules['glanceclient'] = MockGlance69import ensure_enough # noqa70ensure_enough.CURRENT_IMAGE_NAME = 'vgcnbwc7-22'71ensure_enough.CURRENT_IMAGE = {'id': 'dead-beef-cafe'}72def test_launch_server():73 server = ensure_enough.launch_server('testing', 'c.c10m55')74 assert server.name == 'testing'75 server = ensure_enough.launch_server('testing2', 'z.c10m55')76 assert server.name == 'testing2'77def test_wait_for_state():78 server = ensure_enough.launch_server('testing', 'c.c10m55')79 assert ensure_enough.wait_for_state('testing', 'ACTIVE') == server80def test_nonconflicting_name():81 # Clear list of servers.82 sys.modules['novaclient'].client.servers._clear()83 ensure_enough.MAX_SERVER_POOL = 1084 for i in range(10):85 ensure_enough.launch_server('testing-%04d' % i, 'c.c10m55')86 # TODO: find a better way to do this.87 # n = ensure_enough.non_conflicting_name('testing', sys.modules['novaclient'].client.servers.list())88 # assert n == 'testing-0010', "%s != %s" % (n, 'testing-0010')89 # Now we'll fill that slot.90 ensure_enough.launch_server('testing-0010', 'c.c10m55')91 # And the next one sohuld be a timestamp.92 n = ensure_enough.non_conflicting_name('testing', sys.modules['novaclient'].client.servers.list())93 # Good until 2020.94 assert n.startswith('testing-15')95def test_nonsimilar_resource_names():96 sys.modules['novaclient'].client.servers._clear()97 # Clear list of servers.98 ensure_enough.MAX_SERVER_POOL = 10099 for i in range(10):100 ensure_enough.launch_server('compute-general-%04d' % i, 'c.c10m55')101 servers_rm, servers_ok = ensure_enough.identify_server_group('compute-general')102 assert len(servers_rm) == 0103 assert len(servers_ok) == 10104 servers_rm, servers_ok = ensure_enough.identify_server_group('compute-highmem')105 assert len(servers_rm) == 0106 assert len(servers_ok) == 0107 for i in range(4):108 ensure_enough.launch_server('compute-highmem-%04d' % i, 'c.c10m55')109 servers_rm, servers_ok = ensure_enough.identify_server_group('compute-general')110 assert len(servers_rm) == 0111 assert len(servers_ok) == 10112 servers_rm, servers_ok = ensure_enough.identify_server_group('compute-highmem')113 assert len(servers_rm) == 0114 assert len(servers_ok) == 4115def test_similar_resource_names():116 with open('resources.yaml', 'r') as handle:117 data = yaml.load(handle)118 resource_keys = data['deployment'].keys()119 for key in resource_keys:120 matching_prefixes = [121 other_key122 for other_key in resource_keys...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python 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