我一直在用Python编写Selenium单元测试。我试图将输出写入一个文件,但由于某种原因,我的代码甚至没有打开该文件。当我在命令行中使用它时,同样的代码也可以工作,但是当我用seltest运行它时,什么都不会发生。webdriverapi中是否有某种限制阻止我这样做?我也没有任何错误。你知道吗
任何帮助都将不胜感激,谢谢!你知道吗
~z~嘶嘶作响
def mailGen(self):
self.email = "tester%s@example.com" % floor(uniform(1,10)*100)
logFile = open('log.txt','w')
logFile.write('')
logFile.write(self.email)
logFile.close()
return self.email
我已经将这段代码复制并粘贴到了控制台中,您可以在下面看到,它工作得非常好。除了它正在打开我的C:/Python33
目录中的文件,这是预期的。你知道吗
>>> def mailGen():
email = "tester%s@example.com" % floor(uniform(1,10)*100)
logFile = open('log.txt','w')
logFile.write('')
logFile.write(email)
logFile.close()
return email
>>> mailGen()
'tester508@example.com'
>>> mailGen()
'tester827@example.com'
>>>
目前没有回答
相关问题 更多 >
编程相关推荐