github.com/bazelbuild/rules_webtesting@v0.2.0/testing/web/webtest_test.py (about)

     1  # Copyright 2016 Google Inc.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #      http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  """Tests for testing.web.webtest."""
    15  
    16  import unittest
    17  
    18  from testing.web import webtest
    19  
    20  
    21  class BrowserTest(unittest.TestCase):
    22  
    23    def testBrowserProvisioningNoCaps(self):
    24      driver = webtest.new_webdriver_session()
    25  
    26      try:
    27        driver.get(webtest.http_address() + "/healthz")
    28        self.assertTrue(driver.current_url)
    29      finally:
    30        driver.quit()
    31  
    32    def testBrowserProvisioningWithCaps(self):
    33      capabilities = {
    34          "acceptInsecureCerts": False,
    35          "pageLoadStrategy": "normal",
    36      }
    37      driver = webtest.new_webdriver_session(capabilities)
    38  
    39      try:
    40        driver.get(webtest.http_address() + "/healthz")
    41        self.assertTrue(driver.current_url)
    42      finally:
    43        driver.quit()
    44  
    45  
    46  if __name__ == "__main__":
    47    unittest.main()