将python模块导入Robot Framework时出现此错误。但是当我在外面独立运行.py模块时,它运行正常。有人能告诉我为什么会出现splitgophertype错误
[ ERROR ] Error in file 'C:\Users\karthicm\DigitalMP3_Project\__init__.html' in table 'Settings': Importing test library 'C:\RF_Library\CP_Web_SignInPage.py' failed: ImportError: cannot import name splitgophertype
Traceback (most recent call last):
File "C:\RF_Library\CP_Web_SignInPage.py", line 1, in <module>
from lib_Operations_UILink import ClickLink
File "C:\RF_Library\lib_Operations_UILink.py", line 6, in <module>
from lib_TestSetUp import is_element_present, Fnc_WaitForPageToLoad,\
File "C:\RF_Library\lib_TestSetUp.py", line 6, in <module>
from selenium import webdriver
File "C:\Python27\Lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox
File "C:\Python27\Lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 27, in <module>
from selenium.webdriver.firefox.extension_connection import ExtensionConnection
File "C:\Python27\Lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 22, in <module>
from selenium.webdriver.remote.remote_connection import RemoteConnection
File "C:\Python27\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 23, in <module>
import urllib2 as url_request
File "C:\Python27\Lib\site-packages\urllib2.py", line 110, in <module>
from urllib import (unwrap, unquote, splittype, splithost, quote,
PYTHONPATH:
C:\Python27
C:\RF_Library
C:\Python27\Lib\site-packages
C:\Python27\lib\site-packages\robot\libraries
C:\Python27\lib\site-packages
C:\Python27\lib\site-packages\pip-1.2.1-py2.7.egg
C:\Python27
C:\RF_Library
C:\Python27\Lib\site-packages\selenium\webdriver
C:\Users\karthicm\DigitalMP3_Project
C:\Windows\system32\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg-info
C:\Python27\lib\site-packages\wx-2.8-msw-unicode
.
[ ERROR ] Error in file 'C:\Users\karthicm\DigitalMP3_Project\__init__.html' in table 'Settings': Importing test library 'C:\RF_Library\lib_AmazonMusic.py' failed: ImportError: cannot import name splitgophertype
Traceback (most recent call last):
File "C:\RF_Library\lib_AmazonMusic.py", line 6, in <module>
from lib_Operations_Common import is_element_present, ConvertToSeconds, FloatEquals
File "C:\RF_Library\lib_Operations_Common.py", line 6, in <module>
from selenium.webdriver.common.action_chains import ActionChains
File "C:\Python27\Lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox
File "C:\Python27\Lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 27, in <module>
from selenium.webdriver.firefox.extension_connection import ExtensionConnection
File "C:\Python27\Lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 22, in <module>
from selenium.webdriver.remote.remote_connection import RemoteConnection
File "C:\Python27\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 23, in <module>
import urllib2 as url_request
File "C:\Python27\Lib\site-packages\urllib2.py", line 110, in <module>
from urllib import (unwrap, unquote, splittype, splithost, quote,
我的测试库导入
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import datetime
import os.path
import lib_CreateMasterDictionary
我尝试使用的同一个测试库中的一个方法是
def initiate_setup(self, profile="default"):
"""
This function is initial setup for each test script
The function takes 2 agrument - self and a profile for Firefox, only if necessary
"""
try:
current_profile = False
if TARGET_BROWSER == "Firefox" and profile:
current_profile = setup_firefox_profile(profile)
self.wd_handle = webdriver_initiate(current_profile)
if TARGET_BROWSER == "Chrome" and profile:
setup_Chrome_plugin(self.wd_handle, profile)
#if TARGET_BROWSER == "IE" and profile:
# Developer for this part of the code did not have access to IE, also IE sucks.
self.wd_handle.implicitly_wait(5)
self.wd_handle.maximize_window()
self.base_url = HOMEPAGE_AMAZON
self.verificationErrors = []
today = datetime.date.today()
string_today = str(today)
string_today = string_today.replace('-', '')
self.string_today = string_today
if not os.path.exists(TEST_DIRECTORY+"/"+string_today):
os.makedirs(TEST_DIRECTORY+"/"+string_today)
self.resultFile = open(RESULT_FILE, 'a') # opening file for output
result_file2 = self.resultFile
global ElementMappingDictionary
Obj_MasterDictObj = lib_CreateMasterDictionary.CLS_MasterDictionaryBySheet(Str_ExcelPath, Str_SheetName)
ElementMappingDictionary = Obj_MasterDictObj.Fnc_ReturnElementMasterDict(Str_ExcelPath, Str_SheetName)
except Exception as ex:
if not ex:
print ex