Best Python code snippet using play_selenium_python
conftest.py
Source:conftest.py
...33import {{cookiecutter.project_slug}}34from {{cookiecutter.project_slug}}.config import DEFAULT_PAGES35{%- if cookiecutter.pytest_play == 'y' %}36@pytest.fixture(autouse=True)37def bdd_vars(bdd_vars, variables, skin, data_base_path):38 """ Inject bdd_vars so they becomes available in play39 fixture """40 bdd_vars['data_base_path'] = data_base_path41 return bdd_vars42@pytest.fixture43def data_base_path():44 """ where pytest-play json files live """45 here = os.path.abspath(os.path.dirname(__file__))46 data_path = os.path.join(here, 'data')47 if 'WIN' in platform.system().upper():48 data_path = data_path.replace(os.sep, os.sep*2)49 return data_path50{%- endif %}51@pytest.fixture(scope="session")...
bdd_reader.py
Source:bdd_reader.py
1#!/usr/bin/env python2# coding: utf-83"""4bdd_reader5----------------------------------------------6A class for converting BDDs created by ProbLog using the dd library to the7input format required for the OscaR implementation.8@author: Anna Latour9@email: a.l.d.latour@liacs.leidenuniv.nl10Relevant papers:11 Stochastic Constraint Propagation for Mining Probabilistic Networks.12 A.L.D. Latour, B. Babaki, and S. Nijssen. IJCAI 201913 Stochastic Constraint Propagation for Mining Probabilistic Networks.14 A.L.D. Latour, B. Babaki, Daniël Fokkinga, Marie Anastacio,15 Holger Hoos, and S. Nijssen. Submitted to the Artificial16 Intelligence Journal in April 2020.17Licensed under MIT (https://github.com/latower/SCPMD-solving/blob/master/LICENSES/LICENSE).18"""19import tempfile, subprocess, os, sys20from collections import namedtuple21BddNode = namedtuple('BDDNode', ['id', 'varid', 'hi', 'lo'])22Variable = namedtuple('Variable', ['id', 'pweight', 'nweight', 'is_decision'])23BDD = namedtuple('BDD', ['bdd_nodes', 'bdd_vars', 'roots', 'max_vars'])24def read_bdd(filename):25 with open(filename) as f:26 nn, nv = map(int, f.readline().strip().split())27 bdd_vars = [Variable(i, 1.0, 1.0, False) for i in range(nv)]28 roots = set(map(int, f.readline().strip().split()))29 bdd_nodes = [None] * nn30 for i in range(nn):31 varid, lo, hi = map(int, f.readline().strip().split())32 bdd_nodes[i] = BddNode(i, varid, hi, lo)33 weights = list(map(float, f.readline().strip().split()))34 for i in range(nv):35 bdd_vars[i] = bdd_vars[i]._replace(pweight=weights[2*i],36 nweight=weights[2*i + 1])37 max_vars = set(map(int, f.readline().strip().split()))38 for v in max_vars:39 bdd_vars[v] = bdd_vars[v]._replace(is_decision=True)40 return BDD(bdd_nodes, bdd_vars, roots, max_vars)41def create_dot(bdd):42 dot_str = 'digraph G {\n\tntrue [shape=box,label="1"];\n\tnfalse [shape=box,label="0"];\n'43 for node in bdd.bdd_nodes:44 description = 'label="v%d (%d)"'%(node.varid, node.id)45 if bdd.bdd_vars[node.varid].is_decision:46 description += ',shape=diamond'47 dot_str += '\tn%d [%s];\n'%(node.id, description)48 for node in bdd.bdd_nodes:49 for ctype in ('hi', 'lo'):50 child = getattr(node, ctype)51 if child == -2:52 target = 'ntrue'53 elif child == -1:54 target = 'nfalse'55 else:56 target = 'n%d'%child57 properties = []58 bvar = bdd.bdd_vars[node.varid]59 if not bvar.is_decision:60 if ctype == 'lo':61 w = bvar.nweight62 else:63 w = bvar.pweight64 properties.append('label="%.2f"'%w)65 if ctype == 'lo':66 properties.append('style=dashed')67 properties = ','.join(properties)68 if properties:69 properties = '[%s]'%properties70 dot_str += '\tn%d -> %s%s;\n'%(node.id, target, properties)71 dot_str += '}\n'72 return dot_str73def draw_bdd(bdd, pdfname):74 dot_str = create_dot(bdd)75 _, dotfile = tempfile.mkstemp()76 with open(dotfile, 'w') as f:77 print(dot_str, file=f)78 subprocess.run(['dot', '-Tpdf', dotfile, '-o', pdfname])79 os.remove(dotfile)80if __name__ == '__main__':81 if len(sys.argv) != 3:82 print('usage: %s BDD_FILE PDF_FILE'%sys.argv[0])83 exit(1)84 bdd = read_bdd(sys.argv[1])...
test_plugin_seleniun_int.py
Source:test_plugin_seleniun_int.py
1# -*- coding: utf-8 -*-2import pytest3@pytest.fixture4def bdd_vars():5 """ Simulate integration with play_selenium """6 return {'using': 'bdd_vars'}7def test_play_variables(play, bdd_vars):8 """ If you provide values inside a pytest-play section of your pytest-variables9 file, they become available to pytest-play """10 assert 'date_format' in play.variables11 assert 'date_format' not in bdd_vars12 assert play.variables['date_format'] == 'YYYYMMDD'...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!