0
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.

But instead of picking an identifier which is "18753" in this case, it's picking below value and putting in Search :

{{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;"><Identifier>18754</Identifier>

After investigation i found this value is coming from developer tool:

Omi
  • 1
  • 1
  • Do you mean you want to view the xml file using Edge browser, then, use selenium to get the special node value? Why not directly read the xml document in your application and get the node value, then, using selenium to open Edge browser and based on the xml node value to search. – Zhi Lv Apr 28 '20 at 11:00
  • Hi Zhi Lv - MSFT, I didn't understand the resolution.. I can view/open xml file in edge browser, but while picking up the xml node values to search in web app is not working .. So instead of picking value from XML, it picks node element value from developers tool.. While same code works fine in Chrome & Firefox. But in Edge i don't under instead of picking node value directly why it's opening developers tool and pick value from it. – Omi Apr 29 '20 at 01:28
  • In the previous comment, I think we could read the XML node value using C# (or use your application language, you could refer to [this link](https://stackoverflow.com/questions/17590182/how-to-get-the-xml-node-value-in-string)), after getting the node value, we could use webdriver to open Edge browser and navigate to the web site (your web application), and then find elements based on the node value. Can you set a debugger in the `String xml = driver.getPageSource();` and post the "xml" value? Might be we could based on this value to find a workaround. – Zhi Lv Apr 29 '20 at 15:55

1 Answers1

0

Try replacing

String appID = xml.split("<Identifier>")[1].split("</Identifier>")[0];

With

String appID = xml.split("<Identifier>")[0];
David Buck
  • 3,752
  • 35
  • 31
  • 35