大佬 请教一下,这种没有任何属性的元素如何取值呢,用获取元素文本也取不到,还有其他方式能取到这个值么,我看元素定位方式里没有文本方式定位
<p><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">2024-09-23 07:47:12.875485 - Debug - WEB操作[断言元素属性]开始</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">2024-09-23 07:47:13.332473 - Error - 无法定位元素 'By: </span><img src="http://talk-cdn.liumatest.cn/0d8e8ae2-b0e3-411f-b8f7-e1e7b4159d15.png" style="max-width: 100%;"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">xpath Expression: //*[@id="ice-container"]/div/div/div[2]/div[1]/div[2]/div[2]/text()'</span></p><p><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">2024-09-23 07:47:13.332580 - Debug - WEB操作[断言元素属性]结束</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">2024-09-23 07:47:13.787756 - Error - Message: invalid selector: The result of the xpath expression "//*[@id="ice-container"]/div/div/div[2]/div[1]/div[2]/div[2]/text()" is: [object Text]. It should be an element. (Session info: chrome=91.0.4472.77)</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">2024-09-23 07:47:13.798658 - Error - 程序错误信息:</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">Traceback (most recent call last):</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/usr/local/lib/python3.8/unittest/case.py", line 60, in testPartExecutor yield</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/usr/local/lib/python3.8/unittest/case.py", line 676, in run self._callTestMethod(testMethod)</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/usr/local/lib/python3.8/unittest/case.py", line 633, in _callTestMethod method()</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/lm/lm_case.py", line 29, in testEntrance WebTestCase(test=self).execute()</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/testcase.py", line 30, in execute self.loop_execute(self.case_message['optList'], [])</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/testcase.py", line 64, in loop_execute raise e</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/testcase.py", line 57, in loop_execute step.execute()</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/teststep.py", line 39, in execute self.result = func(self.test, self.driver, **opt_content)</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/find_opt.py", line 295, in assert_ele_attribute return Assertion(test, driver).assert_ele_attribute(kwargs["element"]["element"], kwargs["data"]["name"],</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/driver/assertionOpt.py", line 166, in assert_ele_attribute raise e</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/driver/assertionOpt.py", line 163, in assert_ele_attribute actual = self.find_element(element).get_attribute(name)</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/driver/__init__.py", line 18, in find_element raise e</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/liuma/core/web/driver/__init__.py", line 13, in find_element element = self.driver.find_element(*tuple(ele))</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, {</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response)</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace)</span><br style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;" data-filtered="filtered"><span style="color: rgb(96, 98, 102); font-family: Avenir, Helvetica, Arial, sans-serif;">selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: The result of the xpath expression "//*[@id="ice-container"]/div/div/div[2]/div[1]/div[2]/div[2]/text()" is: [object Text]. It should be an element. (Session info: chrome=91.0.4472.77)</span><br data-filtered="filtered"></p>
收藏(0)
分享
相关标签:
注意:本文归作者所有,未经作者允许,不得转载