我需要在机器人框架中有条件地执行一些关键字,但我不知道该怎么做,它不起作用.我尝试了很多选项,但我想我的"IF-ELSE"声明完全错了..
Choose Particular Filter ${FILTER} And Uncheck All Values
${bool}= is filter opened ${AVAILABLE FILTERS} ${FILTER}
${uncheck_all_button}= run keyword if "${bool}" == "True" uncheck all in filter ${AVAILABLE FILTERS} ${FILTER}
... click element ${uncheck_all_button}
... ELSE
... Set variable ${particular_filter}: find particular filter ${AVAILABLE FILTERS} ${FILTER}
... click element ${particular_filter}
... Set variable ${uncheck_all_button}: uncheck all in filter ${AVAILABLE FILTERS} ${FILTER}
... click element ${uncheck_all_button}
Run Code Online (Sandbox Code Playgroud)
它失败了:Variable '${particular_filter}' not found.
但是如果我运行它,它甚至不应该转到ELSE分支,因为$ {bool}是True ...我的自定义函数is filter opened只检查过滤器是否已经打开 - 如果是,则返回True.我的自定义函数uncheck …
我想问一下机器人中是否有一个选项(使用selenium2library)来设置一些隐含的等待所有元素,这些元素应该在测试期间只在一个地方找到?目前我将EACH元素中的等待放在我的关键字中(看起来不太好)
Wait Until Element Is Visible ${repeated for each element}
Run Code Online (Sandbox Code Playgroud)
前端是在Angular中制作的.我发现它可能是麻烦的原因,我也发现了一些扩展的selenium2library,但是我不能使用这个扩展库,因为我只能使用官方支持的库(现在只是selenium2library)...
我还尝试在导入库时设置implcit等待和超时,但它似乎没有帮助(如果我在每个元素之前评论我的"等待",它会再次开始失败)
Library Selenium2Library 10 15
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?在这种情况下,我真的必须在每个元素之前等待吗?
谢谢
automated-tests wait robotframework angularjs selenium2library
使用Robot框架和Selenium2Library处理iframe时遇到问题.它抛出错误:
WebDriverException: Message: unknown error: unhandled inspector error: {"code":-
32000,"message":"Cannot find context with specified id"}
(Session info: chrome=55.0.2883.87)
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)
Run Code Online (Sandbox Code Playgroud)
我的测试代码是:
Fill In Description ${description}
Wait Until Element Is Visible ${FRAME} 40
Select Frame ${FRAME}
wait until page contains element ${IFRAME BODY}
Click Element ${IFRAME BODY}
wait until page contains element ${IFRAME BODY}
Clear Element Text ${IFRAME BODY}
wait until page contains element ${IFRAME BODY}
Input Text ${IFRAME BODY} ${description}
Unselect Frame
Run Code Online (Sandbox Code Playgroud)
它失败了 Input …
selenium automated-tests robotframework selenium-webdriver selenium2library
我需要将cookie值传递给Get request关键字以使其正常工作,但它仍然失败.我不知道如何在那里正确传递它.关键字的文档说明了标题:"标题:与请求一起使用的标题字典"我有这样的测试,使用库RequestsLibrary:
Check request and response
Do Local Login ${username} ${password} #this is my custom keyword - opens browser and logs in using UI
${cookie_value}= Get Cookie Value JSESSIONID
Create Session session1 https://oururl.com verify=${False} cookies=${cookie_value}
${dict}= Create Dictionary Cookie=${cookie_value}
${resp}= Get request session1 /somepage/request headers=${dict}
Run Code Online (Sandbox Code Playgroud)
它总是回归TypeError: string indices must be integers.追溯:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\RequestsLibrary\RequestsKeywords.py", line 370, in get_request
session, uri, params, headers, json, redir, timeout)
File "c:\python27\lib\site-packages\RequestsLibrary\RequestsKeywords.py", line 897, in _get_request
verify=self.verify) …Run Code Online (Sandbox Code Playgroud) python cookies automated-tests robotframework python-requests
从数据库我得到格式的结果:
result = ([('A', 210L), ('B', 1L), ('C', 269L)], 3)
Run Code Online (Sandbox Code Playgroud)
我需要在Python中将其更改为:
[{'description':'A','sum':210},{'description':'B','sum':1},{'description':'C','sum':269}]
Run Code Online (Sandbox Code Playgroud)
我尝试了各种选择,但没有得到我需要的东西..
rows = len(result[0])
description_sum = {}
all_descriptions_sums = []
for i in range(rows):
description_sum['description'] = result[0][i][0]
description_sum['sum'] = int(result[0][i][1])
all_descriptions_sums.append(description_sum)
return all_descriptions_sums
Run Code Online (Sandbox Code Playgroud)
它导致:
[{'description':'C','sum':269},{'description':'C','sum':269},{'description':'C','sum':269}]
Run Code Online (Sandbox Code Playgroud)
因此,在该步骤中all_descriptions_sums.append(description_sum),字典不仅仅附加到列表中,而且还重写了先前的值.
非常感谢你的帮助!
python ×3
angularjs ×1
cookies ×1
dictionary ×1
if-statement ×1
list ×1
python-2.7 ×1
selenium ×1
tuples ×1
wait ×1