小编Cro*_*nax的帖子

如何在机器人框架中使用正则表达式选择子字符串

在名为String的Robot Framework库中,有几个关键字允许我们使用regexp来操作字符串,但这些操作似乎不包括从字符串中选择子字符串.

为了澄清,我打算有一个价格,即€ 1234,00我想从中选择仅4个主要数字,这意味着我留下了1234(我将转换为int以用于验证计算).我有一个正则表达式,允许我这样做,如下所示:

(\d+)[\.\,]

如果我使用Remove String Using Regexp这个正则表达式,我将完全保留我试图删除的内容.如果我使用Get Lines Matching Regexp,我将得到整行,而不仅仅是我想要的结果,如果我使用Get Regexp Matches我会得到正确的结果,除了它将在列表中,然后我将不得不再次操作,这样看起来似乎没有最佳.

我是否只是错过了允许我这样做的关键字,或者我被迫编写自己的自定义关键字,让我这样做?我有点惊讶这个功能似乎不可用,因为这是我想到的第一个用例,当我想到使用带有字符串的正则表达式时......

regex string substring robotframework

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

Selenium Python webdriver:driver.get()不接受变量?

我正在尝试编写一个自动测试脚本,它将为多个URL执行一组操作.我试图这样做的原因是因为我正在测试一个具有多个功能完全相同的前端接口的Web应用程序,所以如果我可以使用单个测试脚本来运行所有这些,并确保基础知识是按顺序,这可以节省我在代码库更改时的回归测试中的大量时间.

我目前的代码如下:

# initialize the unittest framework
import unittest
# initialize the selenium framework and grab the toolbox for keyboard output
from selenium import selenium, webdriver
# prepare for the usage of remote browsers
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class Clubmodule(unittest.TestCase):
    def setUp(self):
    #   load up the remote driver and tell it to use Firefox
        self.driver = webdriver.Remote(
        command_executor="http://127.0.0.1:4444/wd/hub",    
        desired_capabilities=DesiredCapabilities.FIREFOX)
        self.driver.implicitly_wait(3)

    def test_010_LoginAdmin(self):
        driver = self.driver
    #   prepare the URL by loading the list from a textfile
        with open('urllist.txt', 'r') as …
Run Code Online (Sandbox Code Playgroud)

python selenium webdriver selenium-webdriver

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