Я не могу решить следующую проблему:
Ниже приведен мой код на 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()
Я запускаю этот тест, используя следующую команду.
xvfb-run --server-args="-screen 0, 1280x1024x8" python admin-ui-test.py --url 'http://localhost:8080' --username 'test' --password 'test1234'
Ниже мой вывод:
ERROR: test_redirect_to_congito_login_page (__main__.SeleniumTestPack) TypeError: test_redirect_to_congito_login_page() takes exactly 3 arguments (1 given)
Что-то не так я делаю? У меня есть подобные тесты и в других местах, которые с давних пор работают нормально.
Любая помощь будет высоко оценена.