robotframe环境搭建及问题解决

 1.安装

pip install robotframework

pip install robotframework-ride

pip install robotframework-seleniumlibrary==3.0.0 不能版本过高,会有白屏、没有open browser等问题

进入C:\Python37\Scripts目录下,右击ride.py,选择使用python打开。出现RIDE界面表示RIDE安装成功。

 问题1:ride文件打不开

报错信息如下:

F:\Python3.8\Scripts>python ride.py
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 0.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 3.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 4.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 5.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 6.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 7.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 19.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 20.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 21.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 22.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 25.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 26.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 27.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 28.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 29.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 30.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 31.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 32.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 33.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 34.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 35.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 36.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 37.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 38.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 39.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 40.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 43.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 44.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 45.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 46.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 47.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 48.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 49.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 50.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 51.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 52.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 53.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 54.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 55.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 56.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 57.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 58.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 59.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 60.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 61.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 62.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 63.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 67.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 68.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 69.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 70.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 71.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 13.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 14.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 0.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 3.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 4.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 5.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 6.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 7.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 19.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 20.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 21.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 22.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 25.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 26.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 27.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 28.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 29.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 30.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 31.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 32.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 33.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 34.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 35.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 36.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 37.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 38.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 39.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 40.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 43.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 44.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 45.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 46.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 47.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 48.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 49.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 50.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 51.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 52.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 53.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 54.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 55.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 56.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 57.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 58.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 59.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 60.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 61.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 62.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 63.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 67.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 68.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 69.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 70.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 71.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 13.
Traceback (most recent call last):
File "F:\Python3.8\lib\site-packages\robotide\application\application.py", line 58, in OnInit
self.frame = RideFrame(self, self._controller)
File "F:\Python3.8\lib\site-packages\robotide\ui\mainframe.py", line 175, in __init__
self._init_ui()
File "F:\Python3.8\lib\site-packages\robotide\ui\mainframe.py", line 279, in _init_ui
self.tree = Tree(self, self.actions,
File "F:\Python3.8\lib\site-packages\robotide\ui\tree.py", line 86, in __init__
self._images = TreeImageList()
File "F:\Python3.8\lib\site-packages\robotide\ui\images.py", line 42, in __init__
TestCaseController: _TreeImage(self, 'robot.png'),
File "F:\Python3.8\lib\site-packages\robotide\ui\images.py", line 80, in __init__
self.normal = self._get_image(image_list, normal)
File "F:\Python3.8\lib\site-packages\robotide\ui\images.py", line 91, in _get_image
img = wx.Image(path, wx.BITMAP_TYPE_PNG).ConvertToBitmap()
wx._core.wxAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NULL), "C") == 0" failed at ..\..\src\common\intl.cpp(1579) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.
Things are going to break, please only change locale by creating wxLocale objects to avoid this!
OnInit returned false, exiting...
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ..\..\src\common\wincmn.cpp(478) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

 

 

解决办法:

在Python安装目录下找到该文件application.py,如我的地址F:\Python3.8\Lib\site-packages\robotide\application

 

在该位置加上  self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)

 问题二:

robotframework中导入selenium执行脚本后显示'WebDriver' object has no attribute 'find_elements_by_id'

 

robotframework中导入selenium执行脚本后显示'WebDriver' object has no attribute 'find_elements_by_id',经检查是selenium版本导致,版本selenium4不支持find_elements_by_id格式,可以采取以下方式解决:

方法1:降低selenium版本为selenium3

pip uninstall selenium

pip  install selenium==3.141.0

方法2:修改脚本为新的格式

driver.find_element(By.ID, "kw").send_keys("hello")

posted @ 2023-02-06 14:20  我是小菜鸡丫丫  阅读(123)  评论(0编辑  收藏  举报