Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.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/selenium/4.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,如何使用特殊字符验证所选选项文本?_Python_Selenium_Python Unicode - Fatal编程技术网

使用Python Selenium,如何使用特殊字符验证所选选项文本?

使用Python Selenium,如何使用特殊字符验证所选选项文本?,python,selenium,python-unicode,Python,Selenium,Python Unicode,我的选择选项(选定)文本已附加文本:&n b s p; ; ;&n b s p✔;这会产生一个复选标记(✔) 前面有一些空格 类似HTML的: <label for="PSME">PSME:<select id="PSME" name="PSME"><option value="someuniquenumbershere" selected="selected">Lname, Fname&nbsp;&nbsp

我的选择选项(选定)文本已附加文本:&n b s p; ; ;&n b s p✔;这会产生一个复选标记(✔) 前面有一些空格

类似HTML的:

    <label for="PSME">PSME:<select id="PSME" name="PSME"><option value="someuniquenumbershere" selected="selected">Lname, Fname&nbsp;&nbsp;&nbsp;&nbsp;&#x2714;</option>
<option value="">------------</option>

<option value="someuniquenumbershere">.... lots of options here
此代码从不与option.text匹配,且“if”中的结果为true。 如何使此“if”与option.text匹配

我将结果捕获到日志中,并验证了元素是否正确,代码运行时没有错误,当然“if option.text==”与self.TestUserName+不匹配&nbs-p;&nbs-p;&nbs-p;&nbs-p;&nbs-p;&nbs-p;&x27-14;”

{是的,我读过“每个软件开发人员绝对、肯定必须了解Unicode和字符集的绝对最低要求(没有借口!)”,而且该页面确实包含,我仍然迷路。}

(我已经用空格填充了上面的一些文本,以便so能够正确地显示代码。)


谢谢

Python没有某种String.trim()函数吗?当然有:“strip()”,但复选标记需要验证,并且可以更改为我也需要验证的其他内容。因此这是一个字符编码问题?您是否可以改为读取其中一个属性,例如
@选定的
?是的,它似乎是一个字符编码的东西,我想验证文本。
if option.text.endswith(u'&#x 2 7 1 4;)
PSMEMatch = False
try:
    for option in CPSMEElement.find_elements_by_tag_name('option'):
        if option.text == self.TestUserName + "    &#x2714;":
            PSMEMatch = True
            break