Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python+;Selenium:AssertionError:列表不同:[]!=[“这是您给Sto的[99个字符]\\n[183个字符]它。”_Python_Python 3.x_Selenium_Magento_Magento2 - Fatal编程技术网

Python+;Selenium:AssertionError:列表不同:[]!=[“这是您给Sto的[99个字符]\\n[183个字符]它。”

Python+;Selenium:AssertionError:列表不同:[]!=[“这是您给Sto的[99个字符]\\n[183个字符]它。”,python,python-3.x,selenium,magento,magento2,Python,Python 3.x,Selenium,Magento,Magento2,信息 在我当前的项目中,我在Magento云区域工作,并使用Python+Selenium定义我的测试用例。目前,我在第一个开发阶段将Chrome与webdriver 78x结合使用 页面上有一个我试图验证的文本块。根据一个视图,源代码可以正常工作,我只是在最后定义了一个断言来确保验证的安全 但现在的问题是,尽管文本是正确的,但断言每次都变为活动的。我真的不能再解释了 我得到以下信息: self.assertEqual([], self.verificationErrors)

信息

在我当前的项目中,我在Magento云区域工作,并使用Python+Selenium定义我的测试用例。目前,我在第一个开发阶段将Chrome与webdriver 78x结合使用

页面上有一个我试图验证的文本块。根据一个视图,源代码可以正常工作,我只是在最后定义了一个断言来确保验证的安全

但现在的问题是,尽管文本是正确的,但断言每次都变为活动的。我真的不能再解释了

我得到以下信息:

     self.assertEqual([], self.verificationErrors)
    AssertionError: Lists differ: [] != ["'This[99 chars] that\\n you give the Sto[183 chars]it."]

    Second list contains 1 additional elements.
    First extra element 0:
    "'This[99 chars] that\\n you give the Store while using this we[441 chars]ges.' != 'This[99 chars] that you give the Store while using this webs[431 chars]ges.'\nDiff is 1188 characters long. Set self.maxDiff to None to see it."

    - []
    + ["'This[99 chars] that\\n you give the Store while using this we[441 "
    +  "chars]ges.' != 'This[99 chars] that you give the Store while using this "
    +  "webs[431 chars]ges.'\n"
    +  'Diff is 1188 characters long. Set self.maxDiff to None to see it.']

    ----------------------------------------------------------------------
    Ran 11 tests in 117.076s

FAILED (failures=1)
来源

def test_untitled_test_case(self):
    driver = self.driver
    driver.get("https://URL-TO-PROJECT.com")
    self.assertEqual("This privacy policy sets out how this website (hereafter \"the Store\") uses and protects any information that\n you give the Store while using this website. The Store is committed to ensuring that your privacy is protected.\n Should we ask you to provide certain information by which you can be identified when using this website, then\n you can be assured that it will only be used in accordance with this privacy statement. The Store may change\n this policy from time to time by updating this page. You should check this page from time to time to ensure\n that you are happy with any changes.", driver.find_element_by_xpath("(.//*[normalize-space(text()) and normalize-space(.)='Privacy and Cookie Policy'])[3]/following::p[1]").text)
问题

我的问题是错误的,这对吗

我要求的文本太多了吗

是Magento吗


什么是
assertEqual()
?可以在这里找到一个定义:
self.verificationErrors
是如何定义的?driver=self.driver-driver.get(“e”)try:self.assertEqual(“TEXT.”,driver.find_element_by_xpath(./*[规范化空间(TEXT())和规范化空间(.='Privacy and Cookie Policy'])[3]/following::p[1])。TEXT)Exception AssertionError as e:self.verificationErrors.append(str(e))如果要掩盖比较字符串时抛出的断言错误,请删除
Exception AssertionError
。在您提供的示例中,您正在断言
“TEXT”。
等于站点内容,这显然是错误的。