一个下拉框在WINDOW和LINUX上的定位是不相同的,点击一个下拉框WINDOW会把选项定位到第一个选择项,而在LINUX的可视化界面上,下拉框的选项位于最后一个,具体原因不是很清楚。如果出现这样的问题的话,可以采用我博客里自动化测试系列里面八来解决:点开下拉框定位到最后一个,循环调用UP键 直到第一个。
[quote]
Step3
Comment Start Step3
Call Selenium Api click xpath=//td[2]/img //点击一个图片触发下拉框
Sleep 5s
Focus neDropDown //窗体定位
:FOR ${index} IN RANGE 10 //使用robotframework 自带的FOR去循环
\ Run Keyword if '${index}'=='10' Exit For Loop //循环到最后一步 推出循环
\ Press Key Native 38 //模拟鼠标点击UP键盘
Focus neDropDown //再次聚焦
Press Key Native 10 //模拟鼠标点击ENTER键
Sleep 5s
Comment End Start Step3
[/quote]
(FOR下面的 \ 其实并没有的,只是个空格)如下图所示
[img]http://dl.iteye.com/upload/attachment/0084/2026/54495c96-3b6f-3ae1-a8bf-18811d338e3c.jpg[/img]
关于FOR循环的用法,参考官网内容
[url]http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.6.3#for-in-range[/url]
[quote]
Step3
Comment Start Step3
Call Selenium Api click xpath=//td[2]/img //点击一个图片触发下拉框
Sleep 5s
Focus neDropDown //窗体定位
:FOR ${index} IN RANGE 10 //使用robotframework 自带的FOR去循环
\ Run Keyword if '${index}'=='10' Exit For Loop //循环到最后一步 推出循环
\ Press Key Native 38 //模拟鼠标点击UP键盘
Focus neDropDown //再次聚焦
Press Key Native 10 //模拟鼠标点击ENTER键
Sleep 5s
Comment End Start Step3
[/quote]
(FOR下面的 \ 其实并没有的,只是个空格)如下图所示
[img]http://dl.iteye.com/upload/attachment/0084/2026/54495c96-3b6f-3ae1-a8bf-18811d338e3c.jpg[/img]
关于FOR循环的用法,参考官网内容
[url]http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.6.3#for-in-range[/url]
本文介绍了解决在WINDOW和LINUX平台上下拉框定位不同的问题。通过使用Robot Framework进行自动化测试,确保无论在哪种操作系统中,都能准确地将下拉菜单定位到首个选项。

被折叠的 条评论
为什么被折叠?



