Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 烧瓶试验与硒_Python_Selenium_Flask - Fatal编程技术网

Python 烧瓶试验与硒

Python 烧瓶试验与硒,python,selenium,flask,Python,Selenium,Flask,我试图让教程在这里为烧瓶测试工作 特别是在 使用LiveServer进行测试 如果希望通过Selenium或其他无头浏览器(如PhantomJS)完成测试,可以使用LiveServerTestCase: import urllib2 from flask import Flask from flask_testing import LiveServerTestCase class MyTest(LiveServerTestCase): def create_app(self):

我试图让教程在这里为烧瓶测试工作 特别是在 使用LiveServer进行测试 如果希望通过Selenium或其他无头浏览器(如PhantomJS)完成测试,可以使用LiveServerTestCase:

import urllib2
from flask import Flask
from flask_testing import LiveServerTestCase

class MyTest(LiveServerTestCase):

    def create_app(self):
        app = Flask(__name__)
        app.config['TESTING'] = True
        # Default port is 5000
        app.config['LIVESERVER_PORT'] = 8943
        return app

    def test_server_is_up_and_running(self):
        response = urllib2.urlopen(self.get_server_url())
        self.assertEqual(response.code, 200)
因此,我以他们为例,每当我使用selenium进入页面时 它在该URL上找不到任何内容。我试着打印出URL,它将在端口8943上发送到本地主机。我在谷歌上搜索了一下,找不到有人同时使用这两种工具的例子

from flask import Flask
from flask.ext.testing import LiveServerTestCase
import requests
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import unittest

class IntegrationTest(LiveServerTestCase):

    def create_app(self):
        app = Flask(__name__)
        app.config['TESTING'] = True
        app.config['LIVESERVER_PORT'] = 8943
        return app

    def setUp(self):
        self.app = self.create_app()
        self.browser = webdriver.Firefox()
        self.browser.implicitly_wait(3)

    def tearDown(self):
        self.browser.quit()

    def test_get_page(self):
        self.browser.get(self.get_server_url())
        self.assertNotIn("The requested URL was not found on the server.", self.browser.find_element_by_tag_name("body").text)

if __name__ == '__main__':
    unittest.main()
所以我以他们为例,每当我带着它进入页面时 在该URL上找不到任何内容

该测试只是确保URL是可访问的,即返回的状态代码是
200
。因此,由于该URL上没有提供/empty/default服务器响应文档,所以它可以正常工作