【发布时间】:2020-08-11 23:36:18
【问题描述】:
I am trying to get a value(Identifier in my case) from XML to pull some logic rules for a web app. I have managed to get my JavaScript to work on Firefox & Chrome but for Edge, instead of picking an element(Identifier) it's picking an element description from Developers tool.
Test case is:
1. Get an identifier from .XML
2. Go to an application and search using that identifier
For example: .XML
<Application Type="ABCD">
<Identifier>18753</Identifier>
<SalesChannel SalesChannelType="PQRS" SalesChannelSegment="XYZ">
<Identifier>AB1234</Identifier>
My code for this:
driver.get("URL for .XML");
Assert.assertTrue(driver.getPageSource().contains("Identifier"));
String xml = driver.getPageSource();
String appID = xml.split("<Identifier>")[1].split("</Identifier>")[0];
**Code to navigate to web app **
driver.findElement(By.id("oData")).sendKeys(appID);
--It uses appID and proceed with an application.
但在这种情况下,它不是选择一个标识符“18753”,而是选择低于值并放入搜索:
{{a xmlns="http://www.w3.org/1999/xhtml" tabindex="-1" role="treeitem" aria-expanded="true" aria-posinset="1" aria- setsize="20" aria-level="2" style="color: blue; margin-left: -2em;">
经过调查,我发现这个值来自开发者工具:
【问题讨论】:
-
你的意思是要使用Edge浏览器查看xml文件,然后,使用selenium获取特殊节点值?为什么不直接在你的应用程序中读取xml文档并获取节点值,然后,使用selenium打开Edge浏览器,根据xml节点值进行搜索。
-
Hi Zhi Lv - MSFT,我不明白分辨率.. 我可以在边缘浏览器中查看/打开 xml 文件,但是在获取 xml 节点值以在 Web 应用程序中搜索时不起作用.. 因此,它不是从 XML 中选择值,而是从开发人员工具中选择节点元素值。虽然相同的代码在 Chrome 和 Firefox 中运行良好。但是在 Edge 中,我没有直接选择节点值,而是直接选择它为什么要打开开发人员工具并从中选择值。
-
在之前的评论中,我认为我们可以使用C#读取XML节点值(或者使用您的应用程序语言,您可以参考this link),获取节点值后,我们可以使用webdriver打开 Edge 浏览器并导航到网站(您的 Web 应用程序),然后根据节点值查找元素。您可以在
String xml = driver.getPageSource();中设置调试器并发布“xml”值吗?或许我们可以根据这个值找到解决方法。
标签: selenium microsoft-edge web.xml browser-automation