qq_31700085 2020-03-20 00:31 采纳率: 0%
浏览 208

selenium unittest中框架报错

```from selenium import webdriver
from selenium.webdriver.support.select import Select
from time import sleep
import unittest

driver=None

class Webtours(unittest.TestCase):

@classmethod
def setUpClass(cls):
    global driver
    driver=webdriver.Ie()
@classmethod
def tearDownClass(cls):
    driver.quit()
def testOpenWeb(self):
    driver.get("http://localhost:1080/webtours")
    sleep(3)
def testLogin(self):
    sleep(3)
    driver.switch_to.default_content()
    driver.switch_to.frame("body")
    driver.switch_to.frame("navbar")
    driver.find_element_by_name("username").send_keys("zhangsan1")
    driver.find_element_by_name("password").send_keys("1")
    driver.find_element_by_name("login").click()
    sleep(3)

报错如下
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\admin\Desktop\WebTours.py", line 21, in testLogin
    driver.switch_to.frame("body")
  File "E:\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\switch_to.py", line 87, in frame
    raise NoSuchFrameException(frame_reference)
selenium.common.exceptions.NoSuchFrameException: Message: body


----------------------------------------------------------------------
Ran 2 tests in 15.415s

FAILED (errors=1)
>>>
  • 写回答

1条回答 默认 最新

  • dabocaiqq 2020-03-20 11:15
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试