Python Selenium TypeError预期3个参数(1given)

Python Selenium TypeError预期3个参数(1given),python,unit-testing,selenium,selenium-webdriver,webdriver,Python,Unit Testing,Selenium,Selenium Webdriver,Webdriver,我无法解决以下问题: 下面是我的python selenium代码 import unittest import time import argparse, sys, os import traceback from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait fro

我无法解决以下问题:

下面是我的python selenium代码

import unittest
import time
import argparse, sys, os
import traceback
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

class SeleniumTestPack(unittest.TestCase):

    driver = webdriver.Firefox()
    timeout = 30

    def test_all(self):

        admin_base_url = args.url
        cognito_url = "test.auth.us-west-2.amazoncognito.com"
        user_full_name = "test User"
        email = "test@test.com"
        firstName = "Selenium"
        lastName = "User"

        try:

          self.test_redirect_to_congito_login_page(admin_base_url, cognito_url)

          self.delete_geckodriver_log()

        except Exception:

          self.driver.save_screenshot('exception.png')
          self.fail("Exception: %s" % (traceback.format_exc()))

    def test_redirect_to_congito_login_page(self, admin_base_url, cognito_url):
      print "Test navigating to home page redirects to cognito login page"
      self.driver.get(admin_base_url)
      self.wait_for_element_loaded(By.ID, "div-forms")
      page_url = self.driver.current_url
      assert cognito_url in page_url

    def wait_for_element_loaded(self, id_type, id_locator):
      min_timeout = 2
      tries = 0
      retry_limit = 13
      while tries <= retry_limit:
        try:
          tries = tries + 1
          element_present = EC.presence_of_element_located((id_type, id_locator))
          WebDriverWait(self.driver, min_timeout).until(element_present)
          break
        except Exception:
          if tries <= retry_limit:
            continue
          self.fail("Exception waiting for page to load %s : %s" % (id_locator,traceback.format_exc()))

    def delete_geckodriver_log(self):
      #running function at the end of all other invocation ensures all test cases have already ran successfully
      geckodriverfile="geckodriver.log"
      if os.path.isfile(geckodriverfile):
        os.remove(geckodriverfile)
      else:
        print("Error: %s file not found" % geckodriverfile)

    @classmethod
    def tearDown(self):
      # close the browser window
      self.driver.quit()

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='test')
    parser.add_argument('--url',action='store',dest='url',default=None,help='<Required> url link',required=True)
    parser.add_argument('--username',action='store',dest='username',default=None,help='<Required> username',required=True)
    parser.add_argument('--password',action='store',dest='password',default=None,help='<Required> password',required=True)
    parser.add_argument('unittest_args', nargs='*')
    args = parser.parse_args()
    sys.argv[1:] = args.unittest_args
    unittest.main()
以下是我的输出:

ERROR: test_redirect_to_congito_login_page (__main__.SeleniumTestPack)  TypeError: test_redirect_to_congito_login_page() takes exactly 3 arguments (1 given)
我做错什么了吗?我在其他地方也做过类似的测试,很长一段时间以来效果都很好


任何帮助都将不胜感激。

这个解决方案对我来说非常陌生

<强>函数名称不应以“TestEy”>开始(否则将被视为单独的测试用例)


我重命名了函数名,它工作正常

您应该将
cognito\u url=“test.auth.us-west-2.amazoncognito.com”
更改为
cognito\u url=”http://test.auth.us-west-2.amazoncognito.com“
@demouser123不,没关系。这是由selenium内部处理的。请阅读我的答案!有人知道什么是“def测试(自我)”吗?我从旧的测试中获取了这行代码。好的,我知道了。“任何以
test\uuu
开头的方法都将被视为一个测试用例。”即我有一个测试用例,其中我有多个执行单个任务的小方法。
ERROR: test_redirect_to_congito_login_page (__main__.SeleniumTestPack)  TypeError: test_redirect_to_congito_login_page() takes exactly 3 arguments (1 given)