小编Ron*_*onu的帖子

用于处理弹出浏览器窗口的Python webdriver,它不是警报

我正在开发一个Web应用程序,在其中单击某个链接会出现另一个弹出窗口.弹出窗口不是警报,而是一个表单,其中包含用户输入的各种字段,然后单击"下一步".

如何使用selenium处理/自动化此弹出窗口.

摘要: -

  1. 点击超链接(网址) - "点击这里"
  2. 用户注册表单显示为弹出窗口
  3. 数据由用户填写
  4. 单击下一步/提交按钮.
  5. 另一个下一个重定向到另一个页面/表单'用户个人信息页'
  6. 个人信息由用户填写
  7. 点击"下一步/提交"
  8. 弹出消失了.
  9. 现在进一步处理原始/基页.

python selenium webdriver

22
推荐指数
2
解决办法
5万
查看次数

如何引用yaml文件中的值?

我写了一个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 文件中使用引用?

yaml

8
推荐指数
1
解决办法
6972
查看次数

深入检查两个python词典,并获得报告表单中的差异

说在python中有两个字典 -

Dict1

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)

python

4
推荐指数
1
解决办法
1048
查看次数

Pytest 参数化测试用例共享一个类变量

我最近开始使用 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”变量的值使用到当前测试用例中?

python pytest

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×3

pytest ×1

selenium ×1

webdriver ×1

yaml ×1