• <small id='PSGNc'></small><noframes id='PSGNc'>

    <legend id='PSGNc'><style id='PSGNc'><dir id='PSGNc'><q id='PSGNc'></q></dir></style></legend>
    • <bdo id='PSGNc'></bdo><ul id='PSGNc'></ul>
    <i id='PSGNc'><tr id='PSGNc'><dt id='PSGNc'><q id='PSGNc'><span id='PSGNc'><b id='PSGNc'><form id='PSGNc'><ins id='PSGNc'></ins><ul id='PSGNc'></ul><sub id='PSGNc'></sub></form><legend id='PSGNc'></legend><bdo id='PSGNc'><pre id='PSGNc'><center id='PSGNc'></center></pre></bdo></b><th id='PSGNc'></th></span></q></dt></tr></i><div id='PSGNc'><tfoot id='PSGNc'></tfoot><dl id='PSGNc'><fieldset id='PSGNc'></fieldset></dl></div>

      1. <tfoot id='PSGNc'></tfoot>

        InvalidArgumentException:消息:使用&#39;的无效参数:&#39;必须是字符串

        时间:2024-08-10

        <i id='LSG1X'><tr id='LSG1X'><dt id='LSG1X'><q id='LSG1X'><span id='LSG1X'><b id='LSG1X'><form id='LSG1X'><ins id='LSG1X'></ins><ul id='LSG1X'></ul><sub id='LSG1X'></sub></form><legend id='LSG1X'></legend><bdo id='LSG1X'><pre id='LSG1X'><center id='LSG1X'></center></pre></bdo></b><th id='LSG1X'></th></span></q></dt></tr></i><div id='LSG1X'><tfoot id='LSG1X'></tfoot><dl id='LSG1X'><fieldset id='LSG1X'></fieldset></dl></div>
          • <bdo id='LSG1X'></bdo><ul id='LSG1X'></ul>

            <tfoot id='LSG1X'></tfoot>

              <small id='LSG1X'></small><noframes id='LSG1X'>

              <legend id='LSG1X'><style id='LSG1X'><dir id='LSG1X'><q id='LSG1X'></q></dir></style></legend>

                  <tbody id='LSG1X'></tbody>
                • 本文介绍了InvalidArgumentException:消息:使用&#39;的无效参数:&#39;必须是字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是Python的新手,正在尝试创建可重用的代码。当我试图通过传递在Login类下使用的所有参数来调用test_main.py中的类Login和函数login_user时,收到一个错误,即InvalidArgumentException:Message:Invalid ArgumentException:‘using’必须是字符串。

                  在pytest上运行的test_main.py文件。

                  locators_test是包含所有xpath的test_Locators.py文件的类

                  test_Locators.py

                  class Locators_test():
                  
                  loginlink_xpath = "//a[@id='login-link']"
                  login_email = "xxxxx"
                  login_password = "xxxxx"
                  loginemail_id = "dnn_ctr1179_Login_txtEmail"
                  loginpassword_id = "dnn_ctr1179_Login_txtPassword"
                  clicklogin_id = "dnn_ctr1179_Login_btnLogin"
                  

                  test_login.py

                  from Smoketest.locatorfile.test_Locators import Locators_test
                  
                  class Login():
                  
                  def __init__(self,driver):
                  
                      self.driver = driver
                  
                  def login_user(self,driver):
                      try:
                          loginButton = self.driver.find_element((By.XPATH, Locators_test.loginlink_xpath))
                          while loginButton.click() is True:
                              break
                          time.sleep(3)
                          self.driver.execute_script("window.scrollBy(0,300);")
                  
                          EmailField = self.driver.find_element((By.ID, Locators_test.loginemail_id))
                          EmailField.send_keys(Locators_test.login_email)
                  
                          PasswordField = self.driver.find_element((By.ID, Locators_test.loginpassword_id))
                          PasswordField.send_keys(Locators_test.login_password)
                  
                          ClickLogin = self.driver.find_element((By.ID, Locators_test.clicklogin_id))
                          while ClickLogin.click() is True:
                              break
                  
                          time.sleep(5)
                  
                          userName = self.driver.find_element((By.XPATH, Locators_test.username_xpath))
                          print("Logged in as", userName.text)
                  
                  
                  
                      except StaleElementReferenceException or ElementClickInterceptedException or TimeoutException as ex:
                          print(ex.message)
                  

                  test_main.py

                      def test_setup():
                          driver = webdriver.Chrome(executable_path= Locators_test.browser_path)
                          driver.maximize_window()
                          driver.delete_all_cookies()
                          driver.get(homePage)
                          driver.implicitly_wait(5)
                          yield
                          print("test complete")
                  
                  
                  def test_login(test_setup):
                  
                      from Smoketest.pages.test_login import Login
                  
                      lo = Login(driver)
                  lo.login_user(((Locators_test.loginlink_xpath,Locators_test.loginemail_id,Locators_test.login_email,Locators_test.loginpassword_id,Locators_test.login_password,Locators_test.clicklogin_id,Locators_test.username_xpath)))
                  

                  缩进都很好

                  推荐答案

                  我自己修复了它,删除了该行中多余的一对括号

                  loginButton = self.driver.find_element((By.XPATH, Locators_test.loginlink_xpath))

                  正确的方法是

                  loginButton = self.driver.find_element(By.XPATH, Locators_test.loginlink_xpath)

                  PS:这适用于所有行。

                  这篇关于InvalidArgumentException:消息:使用&#39;的无效参数:&#39;必须是字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何通过Chrome上的Python使用Selenium更改多个下载的文件目录,而不必多次启动Web驱动程序和链接? 下一篇:将值从类获取到其他Python

                  相关文章

                  <legend id='74ZCJ'><style id='74ZCJ'><dir id='74ZCJ'><q id='74ZCJ'></q></dir></style></legend>
                  <i id='74ZCJ'><tr id='74ZCJ'><dt id='74ZCJ'><q id='74ZCJ'><span id='74ZCJ'><b id='74ZCJ'><form id='74ZCJ'><ins id='74ZCJ'></ins><ul id='74ZCJ'></ul><sub id='74ZCJ'></sub></form><legend id='74ZCJ'></legend><bdo id='74ZCJ'><pre id='74ZCJ'><center id='74ZCJ'></center></pre></bdo></b><th id='74ZCJ'></th></span></q></dt></tr></i><div id='74ZCJ'><tfoot id='74ZCJ'></tfoot><dl id='74ZCJ'><fieldset id='74ZCJ'></fieldset></dl></div>

                  <small id='74ZCJ'></small><noframes id='74ZCJ'>

                      <bdo id='74ZCJ'></bdo><ul id='74ZCJ'></ul>

                    1. <tfoot id='74ZCJ'></tfoot>