How to use browser_channel method in Playwright Python

Best Python code snippet using playwright-python

run.py

Source:run.py Github

copy

Full Screen

1import argparse2import os3import platform4import sys5from distutils.spawn import find_executable6from six.moves import input7wpt_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))8sys.path.insert(0, os.path.abspath(os.path.join(wpt_root, "tools")))9from . import browser, install, testfiles, utils, virtualenv10from ..serve import serve11logger = None12class WptrunError(Exception):13 pass14class WptrunnerHelpAction(argparse.Action):15 def __init__(self,16 option_strings,17 dest=argparse.SUPPRESS,18 default=argparse.SUPPRESS,19 help=None):20 super(WptrunnerHelpAction, self).__init__(21 option_strings=option_strings,22 dest=dest,23 default=default,24 nargs=0,25 help=help)26 def __call__(self, parser, namespace, values, option_string=None):27 from wptrunner import wptcommandline28 wptparser = wptcommandline.create_parser()29 wptparser.usage = parser.usage30 wptparser.print_help()31 parser.exit()32def create_parser():33 from wptrunner import wptcommandline34 parser = argparse.ArgumentParser(add_help=False)35 parser.add_argument("product", action="store",36 help="Browser to run tests in")37 parser.add_argument("--affected", action="store", default=None,38 help="Run affected tests since revish")39 parser.add_argument("--yes", "-y", dest="prompt", action="store_false", default=True,40 help="Don't prompt before installing components")41 parser.add_argument("--install-browser", action="store_true",42 help="Install the browser from the release channel specified by --channel "43 "(or the nightly channel by default).")44 parser.add_argument("--channel", action="store",45 choices=install.channel_by_name.keys(),46 default=None, help='Name of browser release channel. '47 '"stable" and "release" are synonyms for the latest browser stable '48 'release, "nightly", "dev", "experimental", and "preview" are all '49 'synonyms for the latest available development release. (For WebDriver '50 'installs, we attempt to select an appropriate, compatible version for '51 'the latest browser release on the selected channel.) '52 'This flag overrides --browser-channel.')53 parser._add_container_actions(wptcommandline.create_parser())54 return parser55def exit(msg=None):56 if msg:57 logger.critical(msg)58 sys.exit(1)59 else:60 sys.exit(0)61def args_general(kwargs):62 kwargs.set_if_none("tests_root", wpt_root)63 kwargs.set_if_none("metadata_root", wpt_root)64 kwargs.set_if_none("manifest_update", True)65 kwargs.set_if_none("manifest_download", True)66 if kwargs["ssl_type"] in (None, "pregenerated"):67 cert_root = os.path.join(wpt_root, "tools", "certs")68 if kwargs["ca_cert_path"] is None:69 kwargs["ca_cert_path"] = os.path.join(cert_root, "cacert.pem")70 if kwargs["host_key_path"] is None:71 kwargs["host_key_path"] = os.path.join(cert_root, "web-platform.test.key")72 if kwargs["host_cert_path"] is None:73 kwargs["host_cert_path"] = os.path.join(cert_root, "web-platform.test.pem")74 elif kwargs["ssl_type"] == "openssl":75 if not find_executable(kwargs["openssl_binary"]):76 if os.uname()[0] == "Windows":77 raise WptrunError("""OpenSSL binary not found. If you need HTTPS tests, install OpenSSL from78https://slproweb.com/products/Win32OpenSSL.html79Ensuring that libraries are added to /bin and add the resulting bin directory to80your PATH.81Otherwise run with --ssl-type=none""")82 else:83 raise WptrunError("""OpenSSL not found. If you don't need HTTPS support run with --ssl-type=none,84otherwise install OpenSSL and ensure that it's on your $PATH.""")85def check_environ(product):86 if product not in ("android_weblayer", "android_webview", "chrome", "chrome_android", "firefox", "firefox_android", "servo"):87 config_builder = serve.build_config(os.path.join(wpt_root, "config.json"))88 # Override the ports to avoid looking for free ports89 config_builder.ssl = {"type": "none"}90 config_builder.ports = {"http": [8000]}91 is_windows = platform.uname()[0] == "Windows"92 with config_builder as config:93 expected_hosts = set(config.domains_set)94 if is_windows:95 expected_hosts.update(config.not_domains_set)96 missing_hosts = set(expected_hosts)97 if is_windows:98 hosts_path = r"%s\System32\drivers\etc\hosts" % os.environ.get("SystemRoot", r"C:\Windows")99 else:100 hosts_path = "/etc/hosts"101 if os.path.abspath(os.curdir) == wpt_root:102 wpt_path = "wpt"103 else:104 wpt_path = os.path.join(wpt_root, "wpt")105 with open(hosts_path, "r") as f:106 for line in f:107 line = line.split("#", 1)[0].strip()108 parts = line.split()109 hosts = parts[1:]110 for host in hosts:111 missing_hosts.discard(host)112 if missing_hosts:113 if is_windows:114 message = """Missing hosts file configuration. Run115python %s make-hosts-file | Out-File %s -Encoding ascii -Append116in PowerShell with Administrator privileges.""" % (wpt_path, hosts_path)117 else:118 message = """Missing hosts file configuration. Run119%s make-hosts-file | sudo tee -a %s""" % ("./wpt" if wpt_path == "wpt" else wpt_path,120 hosts_path)121 raise WptrunError(message)122class BrowserSetup(object):123 name = None124 browser_cls = None125 def __init__(self, venv, prompt=True, sub_product=None):126 self.browser = self.browser_cls(logger)127 self.venv = venv128 self.prompt = prompt129 self.sub_product = sub_product130 def prompt_install(self, component):131 if not self.prompt:132 return True133 while True:134 resp = input("Download and install %s [Y/n]? " % component).strip().lower()135 if not resp or resp == "y":136 return True137 elif resp == "n":138 return False139 def install(self, channel=None):140 if self.prompt_install(self.name):141 return self.browser.install(self.venv.path, channel)142 def install_requirements(self):143 if not self.venv.skip_virtualenv_setup:144 self.venv.install_requirements(os.path.join(wpt_root, "tools", "wptrunner", self.browser.requirements))145 def setup(self, kwargs):146 self.setup_kwargs(kwargs)147class Firefox(BrowserSetup):148 name = "firefox"149 browser_cls = browser.Firefox150 def setup_kwargs(self, kwargs):151 if kwargs["binary"] is None:152 if kwargs["browser_channel"] is None:153 kwargs["browser_channel"] = "nightly"154 logger.info("No browser channel specified. Running nightly instead.")155 binary = self.browser.find_binary(self.venv.path,156 kwargs["browser_channel"])157 if binary is None:158 raise WptrunError("""Firefox binary not found on $PATH.159Install Firefox or use --binary to set the binary path""")160 kwargs["binary"] = binary161 if kwargs["certutil_binary"] is None and kwargs["ssl_type"] != "none":162 certutil = self.browser.find_certutil()163 if certutil is None:164 # Can't download this for now because it's missing the libnss3 library165 logger.info("""Can't find certutil, certificates will not be checked.166Consider installing certutil via your OS package manager or directly.""")167 else:168 logger.info("Using certutil %s" % certutil)169 kwargs["certutil_binary"] = certutil170 if kwargs["webdriver_binary"] is None and "wdspec" in kwargs["test_types"]:171 webdriver_binary = self.browser.find_webdriver()172 if webdriver_binary is None:173 install = self.prompt_install("geckodriver")174 if install:175 logger.info("Downloading geckodriver")176 webdriver_binary = self.browser.install_webdriver(dest=self.venv.bin_path)177 else:178 logger.info("Using webdriver binary %s" % webdriver_binary)179 if webdriver_binary:180 kwargs["webdriver_binary"] = webdriver_binary181 else:182 logger.info("Unable to find or install geckodriver, skipping wdspec tests")183 kwargs["test_types"].remove("wdspec")184 if kwargs["prefs_root"] is None:185 prefs_root = self.browser.install_prefs(kwargs["binary"],186 self.venv.path,187 channel=kwargs["browser_channel"])188 kwargs["prefs_root"] = prefs_root189 if kwargs["headless"] is None:190 kwargs["headless"] = True191 logger.info("Running in headless mode, pass --no-headless to disable")192 # Turn off Firefox WebRTC ICE logging on WPT (turned on by mozrunner)193 os.unsetenv('R_LOG_LEVEL')194 os.unsetenv('R_LOG_DESTINATION')195 os.unsetenv('R_LOG_VERBOSE')196 # Allow WebRTC tests to call getUserMedia.197 kwargs["extra_prefs"].append("media.navigator.streams.fake=true")198class FirefoxAndroid(BrowserSetup):199 name = "firefox_android"200 browser_cls = browser.FirefoxAndroid201 def install(self, channel):202 # The install needs to happen in setup so that we have access to all the kwargs203 self._install_browser = True204 return None205 def setup_kwargs(self, kwargs):206 from . import android207 import mozdevice208 # We don't support multiple channels for android yet209 if kwargs["browser_channel"] is None:210 kwargs["browser_channel"] = "nightly"211 if kwargs["prefs_root"] is None:212 prefs_root = self.browser.install_prefs(kwargs["binary"],213 self.venv.path,214 channel=kwargs["browser_channel"])215 kwargs["prefs_root"] = prefs_root216 if kwargs["package_name"] is None:217 kwargs["package_name"] = "org.mozilla.geckoview.test"218 app = kwargs["package_name"]219 if kwargs["device_serial"] is None:220 kwargs["device_serial"] = "emulator-5554"221 # We're running on an emulator so ensure that's set up222 if kwargs["device_serial"].startswith("emulator-"):223 emulator = android.install(logger, reinstall=False, no_prompt=not self.prompt)224 android.start(logger, emulator=emulator, reinstall=False)225 install = False226 if hasattr(self, "_install_browser"):227 if self.prompt_install("geckoview-test"):228 install = True229 apk_path = self.browser.install(self.venv.path,230 channel=kwargs["browser_channel"])231 if "ADB_PATH" not in os.environ:232 adb_path = os.path.join(android.get_sdk_path(None),233 "platform-tools",234 "adb")235 os.environ["ADB_PATH"] = adb_path236 adb_path = os.environ["ADB_PATH"]237 device = mozdevice.ADBDevice(adb=adb_path,238 device=kwargs["device_serial"])239 if install:240 device.uninstall_app(app)241 device.install_app(apk_path)242 elif not device.is_app_installed(app):243 raise WptrunError("app %s not installed on device %s" %244 (app, kwargs["device_serial"]))245class Chrome(BrowserSetup):246 name = "chrome"247 browser_cls = browser.Chrome248 def setup_kwargs(self, kwargs):249 browser_channel = kwargs["browser_channel"]250 if kwargs["binary"] is None:251 binary = self.browser.find_binary(channel=browser_channel)252 if binary:253 kwargs["binary"] = binary254 else:255 raise WptrunError("Unable to locate Chrome binary")256 if kwargs["webdriver_binary"] is None:257 webdriver_binary = self.browser.find_webdriver()258 if webdriver_binary is None:259 install = self.prompt_install("chromedriver")260 if install:261 logger.info("Downloading chromedriver")262 webdriver_binary = self.browser.install_webdriver(263 dest=self.venv.bin_path,264 browser_binary=kwargs["binary"],265 )266 else:267 logger.info("Using webdriver binary %s" % webdriver_binary)268 if webdriver_binary:269 kwargs["webdriver_binary"] = webdriver_binary270 else:271 raise WptrunError("Unable to locate or install chromedriver binary")272 if browser_channel in ("dev", "canary"):273 logger.info("Automatically turning on experimental features for Chrome Dev/Canary")274 kwargs["binary_args"].append("--enable-experimental-web-platform-features")275 # HACK(Hexcles): work around https://github.com/web-platform-tests/wpt/issues/16448276 kwargs["webdriver_args"].append("--disable-build-check")277 if os.getenv("TASKCLUSTER_ROOT_URL"):278 # We are on Taskcluster, where our Docker container does not have279 # enough capabilities to run Chrome with sandboxing. (gh-20133)280 kwargs["binary_args"].append("--no-sandbox")281class ChromeAndroid(BrowserSetup):282 name = "chrome_android"283 browser_cls = browser.ChromeAndroid284 def setup_kwargs(self, kwargs):285 if kwargs.get("device_serial"):286 self.browser.device_serial = kwargs["device_serial"]287 browser_channel = kwargs["browser_channel"]288 if kwargs["package_name"] is None:289 kwargs["package_name"] = self.browser.find_binary(290 channel=browser_channel)291 if kwargs["webdriver_binary"] is None:292 webdriver_binary = self.browser.find_webdriver()293 if webdriver_binary is None:294 install = self.prompt_install("chromedriver")295 if install:296 logger.info("Downloading chromedriver")297 webdriver_binary = self.browser.install_webdriver(298 dest=self.venv.bin_path,299 browser_binary=kwargs["package_name"],300 )301 else:302 logger.info("Using webdriver binary %s" % webdriver_binary)303 if webdriver_binary:304 kwargs["webdriver_binary"] = webdriver_binary305 else:306 raise WptrunError("Unable to locate or install chromedriver binary")307 if browser_channel in ("dev", "canary"):308 logger.info("Automatically turning on experimental features for Chrome Dev/Canary")309 kwargs["binary_args"].append("--enable-experimental-web-platform-features")310 # HACK(Hexcles): work around https://github.com/web-platform-tests/wpt/issues/16448311 kwargs["webdriver_args"].append("--disable-build-check")312class ChromeiOS(BrowserSetup):313 name = "chrome_ios"314 browser_cls = browser.ChromeiOS315 def setup_kwargs(self, kwargs):316 if kwargs["webdriver_binary"] is None:317 raise WptrunError("Unable to locate or install chromedriver binary")318class AndroidWeblayer(BrowserSetup):319 name = "android_weblayer"320 browser_cls = browser.AndroidWeblayer321 def setup_kwargs(self, kwargs):322 if kwargs.get("device_serial"):323 self.browser.device_serial = kwargs["device_serial"]324 if kwargs["webdriver_binary"] is None:325 webdriver_binary = self.browser.find_webdriver()326 if webdriver_binary is None:327 install = self.prompt_install("chromedriver")328 if install:329 logger.info("Downloading chromedriver")330 webdriver_binary = self.browser.install_webdriver(dest=self.venv.bin_path)331 else:332 logger.info("Using webdriver binary %s" % webdriver_binary)333 if webdriver_binary:334 kwargs["webdriver_binary"] = webdriver_binary335 else:336 raise WptrunError("Unable to locate or install chromedriver binary")337class AndroidWebview(BrowserSetup):338 name = "android_webview"339 browser_cls = browser.AndroidWebview340 def setup_kwargs(self, kwargs):341 if kwargs.get("device_serial"):342 self.browser.device_serial = kwargs["device_serial"]343 if kwargs["webdriver_binary"] is None:344 webdriver_binary = self.browser.find_webdriver()345 if webdriver_binary is None:346 install = self.prompt_install("chromedriver")347 if install:348 logger.info("Downloading chromedriver")349 webdriver_binary = self.browser.install_webdriver(dest=self.venv.bin_path)350 else:351 logger.info("Using webdriver binary %s" % webdriver_binary)352 if webdriver_binary:353 kwargs["webdriver_binary"] = webdriver_binary354 else:355 raise WptrunError("Unable to locate or install chromedriver binary")356class Opera(BrowserSetup):357 name = "opera"358 browser_cls = browser.Opera359 def setup_kwargs(self, kwargs):360 if kwargs["webdriver_binary"] is None:361 webdriver_binary = self.browser.find_webdriver()362 if webdriver_binary is None:363 install = self.prompt_install("operadriver")364 if install:365 logger.info("Downloading operadriver")366 webdriver_binary = self.browser.install_webdriver(dest=self.venv.bin_path)367 else:368 logger.info("Using webdriver binary %s" % webdriver_binary)369 if webdriver_binary:370 kwargs["webdriver_binary"] = webdriver_binary371 else:372 raise WptrunError("Unable to locate or install operadriver binary")373class EdgeChromium(BrowserSetup):374 name = "MicrosoftEdge"375 browser_cls = browser.EdgeChromium376 def setup_kwargs(self, kwargs):377 browser_channel = kwargs["browser_channel"]378 if kwargs["binary"] is None:379 binary = self.browser.find_binary(channel=browser_channel)380 if binary:381 kwargs["binary"] = binary382 else:383 raise WptrunError("Unable to locate Edge binary")384 if kwargs["webdriver_binary"] is None:385 webdriver_binary = self.browser.find_webdriver()386 # Install browser if none are found or if it's found in venv path387 if webdriver_binary is None or webdriver_binary in self.venv.bin_path:388 install = self.prompt_install("msedgedriver")389 if install:390 logger.info("Downloading msedgedriver")391 webdriver_binary = self.browser.install_webdriver(dest=self.venv.bin_path, channel=browser_channel)392 else:393 logger.info("Using webdriver binary %s" % webdriver_binary)394 if webdriver_binary:395 kwargs["webdriver_binary"] = webdriver_binary396 else:397 raise WptrunError("Unable to locate or install msedgedriver binary")398 if browser_channel in ("dev", "canary"):399 logger.info("Automatically turning on experimental features for Edge Dev/Canary")400 kwargs["binary_args"].append("--enable-experimental-web-platform-features")401class Edge(BrowserSetup):402 name = "edge"403 browser_cls = browser.Edge404 def install(self, channel=None):405 raise NotImplementedError406 def setup_kwargs(self, kwargs):407 if kwargs["webdriver_binary"] is None:408 webdriver_binary = self.browser.find_webdriver()409 if webdriver_binary is None:410 raise WptrunError("""Unable to find WebDriver and we aren't yet clever enough to work out which411version to download. Please go to the following URL and install the correct412version for your Edge/Windows release somewhere on the %PATH%:413https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/414""")415 kwargs["webdriver_binary"] = webdriver_binary416class EdgeWebDriver(Edge):417 name = "edge_webdriver"418 browser_cls = browser.EdgeWebDriver419class InternetExplorer(BrowserSetup):420 name = "ie"421 browser_cls = browser.InternetExplorer422 def install(self, channel=None):423 raise NotImplementedError424 def setup_kwargs(self, kwargs):425 if kwargs["webdriver_binary"] is None:426 webdriver_binary = self.browser.find_webdriver()427 if webdriver_binary is None:428 raise WptrunError("""Unable to find WebDriver and we aren't yet clever enough to work out which429version to download. Please go to the following URL and install the driver for Internet Explorer430somewhere on the %PATH%:431https://selenium-release.storage.googleapis.com/index.html432""")433 kwargs["webdriver_binary"] = webdriver_binary434class Safari(BrowserSetup):435 name = "safari"436 browser_cls = browser.Safari437 def install(self, channel=None):438 raise NotImplementedError439 def setup_kwargs(self, kwargs):440 if kwargs["webdriver_binary"] is None:441 webdriver_binary = self.browser.find_webdriver(channel=kwargs["browser_channel"])442 if webdriver_binary is None:443 raise WptrunError("Unable to locate safaridriver binary")444 kwargs["webdriver_binary"] = webdriver_binary445class Sauce(BrowserSetup):446 name = "sauce"447 browser_cls = browser.Sauce448 def install(self, channel=None):449 raise NotImplementedError450 def setup_kwargs(self, kwargs):451 kwargs.set_if_none("sauce_browser", self.sub_product[0])452 kwargs.set_if_none("sauce_version", self.sub_product[1])453 kwargs["test_types"] = ["testharness", "reftest"]454class Servo(BrowserSetup):455 name = "servo"456 browser_cls = browser.Servo457 def install(self, channel=None):458 if self.prompt_install(self.name):459 return self.browser.install(self.venv.path)460 def setup_kwargs(self, kwargs):461 if kwargs["binary"] is None:462 binary = self.browser.find_binary(self.venv.path, None)463 if binary is None:464 raise WptrunError("Unable to find servo binary in PATH")465 kwargs["binary"] = binary466class ServoWebDriver(Servo):467 name = "servodriver"468 browser_cls = browser.ServoWebDriver469class WebKit(BrowserSetup):470 name = "webkit"471 browser_cls = browser.WebKit472 def install(self, channel=None):473 raise NotImplementedError474 def setup_kwargs(self, kwargs):475 pass476class WebKitGTKMiniBrowser(BrowserSetup):477 name = "webkitgtk_minibrowser"478 browser_cls = browser.WebKitGTKMiniBrowser479 def install(self, channel=None):480 raise NotImplementedError481 def setup_kwargs(self, kwargs):482 if kwargs["binary"] is None:483 binary = self.browser.find_binary(channel=kwargs["browser_channel"])484 if binary is None:485 raise WptrunError("Unable to find MiniBrowser binary")486 kwargs["binary"] = binary487 if kwargs["webdriver_binary"] is None:488 webdriver_binary = self.browser.find_webdriver(channel=kwargs["browser_channel"])489 if webdriver_binary is None:490 raise WptrunError("Unable to find WebKitWebDriver in PATH")491 kwargs["webdriver_binary"] = webdriver_binary492class Epiphany(BrowserSetup):493 name = "epiphany"494 browser_cls = browser.Epiphany495 def install(self, channel=None):496 raise NotImplementedError497 def setup_kwargs(self, kwargs):498 if kwargs["binary"] is None:499 binary = self.browser.find_binary()500 if binary is None:501 raise WptrunError("Unable to find epiphany in PATH")502 kwargs["binary"] = binary503 if kwargs["webdriver_binary"] is None:504 webdriver_binary = self.browser.find_webdriver()505 if webdriver_binary is None:506 raise WptrunError("Unable to find WebKitWebDriver in PATH")507 kwargs["webdriver_binary"] = webdriver_binary508product_setup = {509 "android_weblayer": AndroidWeblayer,510 "android_webview": AndroidWebview,511 "firefox": Firefox,512 "firefox_android": FirefoxAndroid,513 "chrome": Chrome,514 "chrome_android": ChromeAndroid,515 "chrome_ios": ChromeiOS,516 "edgechromium": EdgeChromium,517 "edge": Edge,518 "edge_webdriver": EdgeWebDriver,519 "ie": InternetExplorer,520 "safari": Safari,521 "servo": Servo,522 "servodriver": ServoWebDriver,523 "sauce": Sauce,524 "opera": Opera,525 "webkit": WebKit,526 "webkitgtk_minibrowser": WebKitGTKMiniBrowser,527 "epiphany": Epiphany,528}529def setup_logging(kwargs, default_config=None, formatter_defaults=None):530 import mozlog531 from wptrunner import wptrunner532 global logger533 # Use the grouped formatter by default where mozlog 3.9+ is installed534 if default_config is None:535 if hasattr(mozlog.formatters, "GroupingFormatter"):536 default_formatter = "grouped"537 else:538 default_formatter = "mach"539 default_config = {default_formatter: sys.stdout}540 wptrunner.setup_logging(kwargs, default_config, formatter_defaults=formatter_defaults)541 logger = wptrunner.logger542 return logger543def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs):544 from wptrunner import wptcommandline545 from six import iteritems546 kwargs = utils.Kwargs(iteritems(kwargs))547 product_parts = kwargs["product"].split(":")548 kwargs["product"] = product_parts[0].replace("-", "_")549 sub_product = product_parts[1:]550 check_environ(kwargs["product"])551 args_general(kwargs)552 if kwargs["product"] not in product_setup:553 raise WptrunError("Unsupported product %s" % kwargs["product"])554 setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product)555 setup_cls.install_requirements()556 affected_revish = kwargs.pop("affected", None)557 if affected_revish is not None:558 # TODO: Consolidate with `./wpt tests-affected --ignore-rules`:559 # https://github.com/web-platform-tests/wpt/issues/14560560 files_changed, _ = testfiles.files_changed(561 affected_revish,562 ignore_rules=["resources/testharness*"],563 include_uncommitted=True, include_new=True)564 # TODO: Perhaps use wptrunner.testloader.ManifestLoader here565 # and remove the manifest-related code from testfiles.566 # https://github.com/web-platform-tests/wpt/issues/14421567 tests_changed, tests_affected = testfiles.affected_testfiles(568 files_changed, manifest_path=kwargs.get("manifest_path"), manifest_update=kwargs["manifest_update"])569 test_list = tests_changed | tests_affected570 logger.info("Identified %s affected tests" % len(test_list))571 test_list = [os.path.relpath(item, wpt_root) for item in test_list]572 kwargs["test_list"] += test_list573 kwargs["default_exclude"] = True574 if install_browser and not kwargs["channel"]:575 logger.info("--install-browser is given but --channel is not set, default to nightly channel")576 kwargs["channel"] = "nightly"577 if kwargs["channel"]:578 channel = install.get_channel(kwargs["product"], kwargs["channel"])579 if channel is not None:580 if channel != kwargs["channel"]:581 logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"],582 channel))583 kwargs["browser_channel"] = channel584 else:585 logger.info("Valid channels for %s not known; using argument unmodified" % kwargs["product"])586 kwargs["browser_channel"] = kwargs["channel"]587 del kwargs["channel"]588 if install_browser:589 logger.info("Installing browser")590 kwargs["binary"] = setup_cls.install(channel=channel)591 setup_cls.setup(kwargs)592 wptcommandline.check_args(kwargs)593 wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner")594 if not venv.skip_virtualenv_setup:595 venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt"))596 # Only update browser_version if it was not given as a command line597 # argument, so that it can be overridden on the command line.598 if not kwargs["browser_version"]:599 kwargs["browser_version"] = setup_cls.browser.version(600 binary=kwargs.get("binary") or kwargs.get("package_name"),601 webdriver_binary=kwargs.get("webdriver_binary"),602 )603 return kwargs604def run(venv, **kwargs):605 setup_logging(kwargs)606 # Remove arguments that aren't passed to wptrunner607 prompt = kwargs.pop("prompt", True)608 install_browser = kwargs.pop("install_browser", False)609 kwargs = setup_wptrunner(venv,610 prompt=prompt,611 install_browser=install_browser,612 **kwargs)613 rv = run_single(venv, **kwargs) > 0614 return rv615def run_single(venv, **kwargs):616 from wptrunner import wptrunner617 return wptrunner.start(**kwargs)618def main():619 try:620 parser = create_parser()621 args = parser.parse_args()622 venv = virtualenv.Virtualenv(os.path.join(wpt_root, "_venv_%s") % platform.uname()[0])623 venv.start()624 venv.install_requirements(os.path.join(wpt_root, "tools", "wptrunner", "requirements.txt"))625 venv.install("requests")626 return run(venv, vars(args))627 except WptrunError as e:628 exit(e.message)629if __name__ == "__main__":630 import pdb631 from tools import localpaths # noqa: F401632 try:633 main()634 except Exception:...

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