【发布时间】:2018-11-15 08:12:27
【问题描述】:
我在 MTM 中进行自动化。
用户界面:
低至:$12,983.30 $108.19 120 5.43%
- 我需要验证数字 12,983.30 是否以 $ 开头
- 我需要验证数字 5.43 是否以 % 结尾
代码: for 1st test
所以我能够验证元素 $12,983.30 存在并且有 $:
"xpath" "//*[+id='-student-loan-finder-form']/div/div[17]/div[2]/div[2]/div[2][text()[contains(., '$')]]" "Total Cost has $" "true"
但我没有成功验证数字是否以 $ 开头:
"xpath" "//*[+id='-student-loan-finder-form']/div/div[17]/div[2]/div[2]/div[2][text()[starts-with(., '$')]]" "Total Cost starts with $" "true"
我做错了什么?
【问题讨论】:
-
欢迎来到 Stack Overflow!请阅读为什么a screenshot of code is a bad idea。粘贴代码并正确格式化。
-
$ 不是第一个字符。您正在提取以“总成本:...”开头的
DIV,因此“T”是第一个字符,这就是在考虑starts-with()时进行比较的内容。 -
总成本: $12,983.30跨度>
-
那么我怎样才能确认 $ 在数字之前呢?
标签: c# selenium-webdriver xpath microsoft-test-manager