```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)
>>>