所以我的代码按预期执行,但是我一直遇到位置参数错误消息,我只是不理解错误。
这是我的代码
import unittest
import re
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class test(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.get("https://foo.bar")
def test_input_maxlength (self):
driver = self.driver
wait = WebDriverWait(driver, 10)
#userInput = 'Howdy there partner long long long long long test. Howdy there partner long long long long long test.'
userInput = 'Howdy there partner.'
inputBoxOneXpath = wait.until(lambda driver: driver.find_element_by_xpath("//input[@type='text']"))
inputBoxTwoXpath = wait.until(lambda driver: driver.find_element_by_xpath("//input[@class='xc-textbox']"))
inputBoxOneXpath.clear()
inputBoxTwoXpath.clear()
inputBoxOneXpath.send_keys(userInput)
wait.until(EC.visibility_of(By.CLASS_NAME, "xc-textbox"))
if (inputBoxOneXpath.get_attribute("value") == inputBoxTwoXpath.get_attribute("value")):
print ("Input text is mirrored.")
else:
print ("Input text is not mirrored, maxlength has been exceeded.")
def tearDown(self):
self.driver.quit
以下是我一直收到的错误消息
File "lab.py", line 24, in test_input_maxlength
wait.until(EC.visibility_of(By.CLASS_NAME, "xc-textbox"))
TypeError: __init__() takes 2 positional arguments but 3 were given