我正在开发一个Web应用程序,在其中单击某个链接会出现另一个弹出窗口.弹出窗口不是警报,而是一个表单,其中包含用户输入的各种字段,然后单击"下一步".
如何使用selenium处理/自动化此弹出窗口.
摘要: -
我写了一个YAML文件,如下:
private_ips:
- 192.168.1.1
- 192.168.1.2
- 192.168.1.3
- 192.168.1.4
testcases:
- name: test_outbound
ip: << I want to use reference to private_ips[0] = '192.168.1.1'
Run Code Online (Sandbox Code Playgroud)
如何在 YAML 文件中使用引用?
说在python中有两个字典 -
mydict1 = {
"Person" :
{
"FName" : "Rakesh",
"LName" : "Roshan",
"Gender" : "Male",
"Status" : "Married",
"Age" : "60",
"Children" :
[
{
"Fname" : "Hrithik",
"Lname" : "Roshan",
"Gender" : "Male",
"Status" : "Married",
"Children" : ["Akram", "Kamal"],
},
{
"Fname" : "Pinky",
"Lname" : "Roshan",
"Gender" : "Female",
"Status" : "Married",
"Children" : ["Suzan", "Tina", "Parveen"]
}
],
"Movies" :
{
"The Last Day" :
{
"Year" : 1990,
"Director" : "Mr. Kapoor" …Run Code Online (Sandbox Code Playgroud) 我最近开始使用 pytest 并且编写了以下课程。
import pytest
import yaml
import random
testcases = list()
class TestSample(object):
test_yml_file = "/tmp/test_inputs.yml"
yamlTestList = list()
with open(test_yml_file, 'r') as testYamlFile:
yamlTestList = yaml.load(testYamlFile)
global testcases
testcases = []
for d in yamlTestList['testcases']:
temp = dict()
for k,v in d.items():
temp[k] = v
testcases.append((temp['testcase'],temp))
last_value = 2
@classmethod
def setup_class(self):
test_sample = TestSample()
@pytest.mark.debug
@pytest.mark.parametrize(('testname', 'testInput'), testcases)
def test_run(self,testname,testInput):
if last_value >= 10:
last_value += random.randint(1,10)
Run Code Online (Sandbox Code Playgroud)
当前问题是 - 对于每个参数化测试,last_value 始终设置为 2。我们如何将先前测试用例中更改的“last_value”变量的值使用到当前测试用例中?