我的 web AUT 的表格中有大约 17 行文本。我已经将每个值分配给临时变量。现在我想将该字符串添加到列表中。
我收到以下错误:
AttributeError: 'str' object has no attribute 'insert'
Run Code Online (Sandbox Code Playgroud)
例如,我有以下文本行:
Text Line 1
Text Line 2
Text Line 3
...
Run Code Online (Sandbox Code Playgroud)
我想将它们添加到列表中,如下所示:
@{mylist} = Text Line 1 | Text Line 2 | Text Line 3
Run Code Online (Sandbox Code Playgroud)
这是我的代码,采用机器人框架格式:
@{list} Create List ${EMPTY}
${list position} Set Variable 0
${number of row} Get Matching Xpath Count //table[@class="GridView"]//tr
${i} Set Variable 2
: FOR ${i} IN RANGE 2 ${number of row}
${i} Convert To String ${i}
${item control} Replace String ${table …Run Code Online (Sandbox Code Playgroud) 我有这段代码,我试图循环遍历类似的 Xpath 来获取它们的文本,并使用机器人农场作业将文本值添加到列表中
: FOR ${i} IN RANGE 2 ${count}+1
\ sleep 10s
\ ${j} Get Text //*[@id="stats"]/div/div/div[2]/div/div/div/div[${i}]/div[1]
\ Append To List @{dbws_datapoints} ${j}
\ log @{dbws_datapoints}[${j}]
Run Code Online (Sandbox Code Playgroud)
代码执行时没有错误,但它没有打印列表,而是将结果记录在日志文件中,如下所示
对于 ${i} 在范围 [ 2 | ] 内 ${count}+1]
我也附上了屏幕截图。 结果文件图像
请帮忙
我尝试使用 Robot Framework 脚本中的进程库中的“运行进程”关键字来运行 perl 脚本,该脚本的参数位于与当前文件夹具有不同路径的文件夹中。
Run Process ./post.pl arg1 arg2 shell=True cwd=/a/b/c
Run Code Online (Sandbox Code Playgroud)
当它运行时,它会抛出一个错误:
Keyword 'Process.Run Process' expected at least 1 non-keyword argument, got 0.
Run Code Online (Sandbox Code Playgroud)
有谁知道可能导致此问题的原因以及如何解决?
任何帮助将不胜感激!谢谢!
在 RobotFramework 中单击转到第二个窗口的链接后,有没有办法调整焦点(即置于前面)第二个窗口?我有一些代码可以在单击后进行屏幕截图,但它只显示第一个窗口
Click link xpath=//*[contains(., "Download certificate")]
sleep 20
Select Window Title=Certificate
Page Screenshot Completion-Certificate
Run Code Online (Sandbox Code Playgroud)
我知道弹出窗口的标题是证书,但我收到错误
ValueError: Unable to locate window with title 'Certificate'
Run Code Online (Sandbox Code Playgroud) 我是机器人框架的新手。我有一个需要标签的innerHTML 的要求。我尝试过这样的事情
Wait Until Page Contains Element xpath: //div[@id="toast-container"]
${temp_elem} = Set Variable xpath: //div[@id="toast-container"]
Log ${temp_elem}
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。请帮忙
当尝试从自定义库访问关键字时,显示错误 InvalidArgumentException
我使用下面的文件夹结构来维护我的测试脚本
Test_Scripts
TestCase
TestSuite1.robot
SupportFiles
RF_CustomLibrary.py
Run Code Online (Sandbox Code Playgroud)
TestSuite1.机器人
*** Settings ***
Library SeleniumLibrary
Library ..\\SupportFiles\\RF_CustomLibrary.py
*** Variables ***
${Browser} Chrome
*** Test cases ***
Sample Test Case
Verify Paste text functionality
*** Keywords ***
Verify Paste text functionality
Set Library Search Order RF_CustomLibrary
Open Browser https://gmail.com ${BROWSER}
Sleep 2s
Maximize Browser Window
Wait Until Keyword Succeeds 60s 2s Element Should Be Visible ${L_Login_btn}
PasteTextFunction id=identifierId Username1
Run Code Online (Sandbox Code Playgroud)
自定义库:RF_CustomLibrary.py
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from SeleniumLibrary …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用“AND”条件为 Robot Framework(RIDE 工具,关键字驱动)中的多个变量设置套件变量,但不能。
下面是我的脚本:
Set Suite Variable ${username} AND
${password} AND
${URL} AND
${Browser}
Run Code Online (Sandbox Code Playgroud)
我面临的错误:
无效的变量语法“${username} AND”。
点列表:
robotframework 3.1.2
[...]
selenium 3.8.1
Run Code Online (Sandbox Code Playgroud)
如果有任何遗漏,请告诉我。提前致谢!
我正在尝试使用 Should Contain
我不明白为什么没有" "in'\r \r'
任何想法我缺少什么?
>>> x='\r \r'
>>> " " in x
True
Run Code Online (Sandbox Code Playgroud) 我的页面上有几个单选按钮系列。我需要单击每个“单选按钮列表”的第一个单选按钮。我决定用 for 循环来做,因为我将来可能需要在每个单选按钮上添加操作。但是 Ride 不喜欢我的循环:它总是显示“错误:数据完整性检查失败。重置更改?”
MyKeyword
[Arguments] ${number}
:FOR ${i} IN RANGE 0 ${number}
\ Run Keyword If '${i}'=='0' Click Element numAlternative1
\ ... ELSE Click Element numAlternative${i}1
Run Code Online (Sandbox Code Playgroud)
我在循环中做错了什么?
如何访问正则表达式中的匹配组?
例如:${line} = Set variable String with-8
我怎么能在单独的变量中获取“String with”部分和数字部分?
我试过:
Test case determining strings and number
${line} = Set variable String with-8
${resultRegexp} = Evaluate re.search('(.+)\\-(\\d+)', '''${line}''')
Log The string(s) part is: ${resultRegexp[0] # or group(1) or so
Log The number part is: ${resultRegexp[1] # or group(2) or so
Run Code Online (Sandbox Code Playgroud)