c# - 在 driver.FindElement(By.XPath) 行上获取 cs1010(Newline in constant) 异常
问题描述
反斜杠和撇号都是 XPath 中常用的字符。也许这总是发生,我现在才看到它,因为我在该行中添加了一个手表,但似乎每个 FindElement 行都抛出了这个异常
引发此错误的行之一是...
if (loadedPage.FindElements(By.XPath("//div[@class='field signature capture']")).Count != 0)
我希望正确的 XPath 语法不会导致异常。
HTML ...
<div class='loaded page' id='page_0' style='height:1030.0px;width:796.0px;background-image:url(/packages/INDle9T1Y4PGRpKDir2KZxuTWoY=/documents/26a85bc2-d735-4135-ad15-d09ce11699f1/pages/0?v=322608);'>
<!-- - cssclass = "field role_#{approval.role.id} #{field.type} #{field.subtype} #{approval.accepted? ? 'accepted' : ''}" -->
<div approval='hc1T31A6E0I6' class='field signature capture ' esl_id='_ircL7s98umMX' id='ircL7s98umMX' style='height:55.0px;left:468.0px;top:369.0px;width:220.0px;' tabindex='1' title='Click on the yellow box to capture your handwritten signature.'>
<div class='loading'> </div>
<div class='required sticky unselectable' role='presentation' style='left:-468.0px;top: 27.5px;'> </div>
<div class='content'>
<div class='name unselectable'>
<div class='cts'>
<img class='checkmark' src='/images/ballot_x.png'>
Click to Sign
</div>
</div>
<div class='bg required' style='height:53.0px;width:218.0px;'><span class='capture-indicator'></span></div>
</div>
</div>
解决方案
虽然这并没有解决关于 FindElement 语法的最初问题,并且它导致 CS1010: Newline in Constant 异常,但这确实帮助我克服了阻碍我的问题。
谢谢昆都克
推荐阅读
- css - 随机平铺背景
- python - python3 ctypes的无效句柄错误 - 昨天工作
- c++ - std::unordered_multiset 的不同元素的数量
- python - 从下拉列表中选择一个值
- java - 使用 JAXB 在 JAVA 中将 CSV 文件转换为层次结构 XML
- c - 您好,我需要一些帮助将此 c 代码转换为与 OpenMP 并行的代码
- mysql - MySQL Workbench:如何在启动期间禁用对所有表的扫描?
- javascript - 在表格单元格中用字符串替换 UL 列表
- python - python中的列表压缩
- postgresql - Postgres 12 升级后,reltuples 设置为 0