get element from web page

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
tzurielya
Posts: 4
Joined: Mon May 18, 2015 3:36 pm

get element from web page

Post by tzurielya » Mon May 25, 2015 3:00 pm

hi,
i am trying to get date form web page.
is there a way in ranorex to get text from the open web using c#?
something like "getelementby..."
??
tnx

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: get element from web page

Post by odklizec » Mon May 25, 2015 3:08 pm

Hi,

Generally speaking, yes, it's possible to get the value of an element via C# code. For example, you can use GetAttributeValueText method to do this. The code could look like this:

Code: Select all

test = repo.Element.GetAttributeValueText("Value");
If you need more detailed help, please post some more details about the web element in question (the best would be Ranorex Snapshot), your Ranorex version, etc...
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

tzurielya
Posts: 4
Joined: Mon May 18, 2015 3:36 pm

Re: get element from web page

Post by tzurielya » Mon May 25, 2015 3:27 pm

this all what i have.
IList<Ranorex.WebDocument> webList = Host.Local.Find<Ranorex.WebDocument>("/dom[@domain='test4.wersystem.com']");

from here have i can use this instance and take information from the web page?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: get element from web page

Post by odklizec » Tue May 26, 2015 6:59 am

I'm afraid, there is not enough info to help you. The code you showed is in my opinion not enough to do what you want. You need an element, from which you want to get the text. Your code points to whole webdocument, not the element containing the "date". Please post the Ranorex snapshot of element in question.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

tzurielya
Posts: 4
Joined: Mon May 18, 2015 3:36 pm

Re: get element from web page

Post by tzurielya » Tue May 26, 2015 8:29 am

i try to explain,
i open chrome with ranorex and open website.
i want to parse this website. i tried to use in HtmlAgilityPack. but because this webpage load with JavaScript i HtmlAgilityPack not being help full for me. so, i search for a way to parse the webpage after is load or in another work to parse the "development tool" (F12) of chrome.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: get element from web page

Post by odklizec » Tue May 26, 2015 9:00 am

If I understand you right, you basically need to load entire web page and parse that page to find an element on it? I think there is still not enough information about how exactly you would like to find the element on that page. You see, even with the page loaded, you still need to know something about the element you would like to find, like its xpath, ID, inner text, tagname, tagvalue, etc. Simply anything that would help to identify the element on page. But maybe I'm misunderstand something?

Anyway, I think you need to use the code like this to load the page:
WebDocument webDoc = "/dom[@domain='www.ranorex.com']";
Now to find something on that page, you will have to use any of available "Find" methods (Find, FindSingle, FindDescendants, etc). Check this page with many "Find" samples...
http://www.ranorex.com/support/user-gui ... mples.html
Last edited by odklizec on Tue May 26, 2015 1:50 pm, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: get element from web page

Post by krstcs » Tue May 26, 2015 1:45 pm

I think part of the problem is that you are trying to re-invent the wheel here. Ranorex already parses the page for you. Learn how Ranorex works and how to use RanoreXPath and I think it will be more clear to you.

http://www.ranorex.com/support/user-guide-20.html
Shortcuts usually aren't...