Watir: XML Element includes Escape Sequences

L

Lisa Cook

I'm working on a test script using Watir. I'm new to Ruby and I'm
struggling with syntax.

if (ARGV[0] == nil)
#caseName = 'Default'
caseName = 'Other'
else
caseName = ARGV[0]
end

root = doc.root
testCasePath = "*TestCases/TestCase[@name='" + caseName + "']"

REXML::XPath.each(doc.root, testCasePath) do |elt|
if (elt.attributes["name"] == caseName)
FirstName =elt.elements["FirstName"].text
puts FirstName


When I get the FirstName value there are a bunch of escape characters
(/n/t/t) coming from the XML document.

Do I have bad syntax or is there another problem?

Thanks.
 
L

Lisa Cook

Never mind. As soon as I posted, I figured it out.

I was using the Visual Studio IDE to create my XML document. I didn't
realize that the IDE added formatting characters. I moved my XML to
notepad and it worked fine.

Hopefully this post will help someone else.

Lisa said:
I'm working on a test script using Watir. I'm new to Ruby and I'm
struggling with syntax.

if (ARGV[0] == nil)
#caseName = 'Default'
caseName = 'Other'
else
caseName = ARGV[0]
end

root = doc.root
testCasePath = "*TestCases/TestCase[@name='" + caseName + "']"

REXML::XPath.each(doc.root, testCasePath) do |elt|
if (elt.attributes["name"] == caseName)
FirstName =elt.elements["FirstName"].text
puts FirstName


When I get the FirstName value there are a bunch of escape characters
(/n/t/t) coming from the XML document.

Do I have bad syntax or is there another problem?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top