now I am testing Ranorex 2.2(using trial version)
How can I create the instance of the WebDocument object related to the instance of the WebBrowser control in Ranorex v2.2?
GetDocument(Control) method is gone?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: GetDocument(Control) method is gone?
All the WebDocuments of a web browser are descendants of the web browser element, so you can just search for the WebDocument relatively inside the browser control:
Regards,
Alex
Ranorex Support Team
Form webBrowser = "pathToWebBrowserForm"; WebDocument doc = webBrowser.FindSingle("//webdocument"); // or use the FindDescendant method doc = webBrowser.FindDescendant<WebDocument>();See the following section in the Ranorex User Guide on how to search relatively using RanoreXPath: http://www.ranorex.com/support/user-gui ... xpath.html
Regards,
Alex
Ranorex Support Team
Re: GetDocument(Control) method is gone?
I don't understand suggested code.
what is 'pathToWebBrowserForm'?
My C# App have form1 and web browser contrl name is webbrowser1 in form1.
How can I write code in this case?
please write example code..
what is 'pathToWebBrowserForm'?
My C# App have form1 and web browser contrl name is webbrowser1 in form1.
How can I write code in this case?
please write example code..
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: GetDocument(Control) method is gone?
'pathToWebBrowserForm' is the RanoreXPath (see http://www.ranorex.com/support/user-gui ... xpath.html) to the web browser form, in your case this is most likely "/form[@controlname='form1']". You get the path if you use Ranorex Spy to track the form that contains your web browser control.gisiman wrote:what is 'pathToWebBrowserForm'?
The WebDocument.GetDocument method available in Ranorex 1.5 is no longer needed, because in Ranorex 2.X all elements (including web elements) form a common element tree that is visible in Ranorex Spy. Every element is identified by a RanoreXPath that can be used to search for a distinct element.
If you are new to Ranorex or have only used Ranorex 1.X before, please read through the Ranorex Tutorial (http://www.ranorex.com/Documentation/Ra ... torial.pdf) and the Ranorex User Guide (http://www.ranorex.com/support/user-guide-20.html). A few more advanced topics are also covered by the Ranorex screencasts (http://www.ranorex.com/support/screencasts.html).
Note, that there are major differences in the methodology of Ranorex 1.X and Ranorex 2.X; Ranorex 2.X is rather a new product than just a new version of Ranorex, consequently Ranorex 1.X and 2.X code is in most cases not compatible!
Regards,
Alex
Ranorex Support Team
Re: GetDocument(Control) method is gone?
Code: Select all
Form frmMain = "/form[@controlname='form1']";
WebDocument webDoc = frmMain.FindSingle("//webdocument");
webDoc.Navigate("http://www.naver.com");
webDoc.WaitForDocumentLoaded();
"Ranorex.ElementNotFoundException: No element found for path '/form[@controlname='form1']' within 10s....
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: GetDocument(Control) method is gone?
I said that this is "most likely" the path to your form, but you should have checked using Ranorex Spy! Please read the Ranorex User Guide on how to analyze your application with Ranorex Spy:
http://www.ranorex.com/support/user-gui ... x-spy.html
Please be aware that attributes in RanoreXPath are case sensitive, please check if the control name of your form is "form1" or "Form1"! You can easily do that by tracking the form in Ranorex Spy!
Regards,
Alex
Ranorex Support Team
http://www.ranorex.com/support/user-gui ... x-spy.html
Please be aware that attributes in RanoreXPath are case sensitive, please check if the control name of your form is "form1" or "Form1"! You can easily do that by tracking the form in Ranorex Spy!
Regards,
Alex
Ranorex Support Team
Re: GetDocument(Control) method is gone?
u are right. 'Form1' is correct name. so I can use instance of web browser control in From1.
but Navagate method don't run.
//this Code run correctly
webBrowserControl1.Navigate("about:blank");
Form frmThis = "/form[@controlname='Form1']";
WebDocument webDoc = frmThis.FindDescendant<WebDocument>();
//Try New Page Loading..but..
webDoc.Navigate("http://www.naver.com"); //Stop Execution at this line. no response...
webDoc.WaitForDocumentLoaded();
please..help me~
but Navagate method don't run.
//this Code run correctly
webBrowserControl1.Navigate("about:blank");
Form frmThis = "/form[@controlname='Form1']";
WebDocument webDoc = frmThis.FindDescendant<WebDocument>();
//Try New Page Loading..but..
webDoc.Navigate("http://www.naver.com"); //Stop Execution at this line. no response...
webDoc.WaitForDocumentLoaded();
please..help me~
Re: GetDocument(Control) method is gone?
Have you tried without the WaitForDocumentLoaded?
If there is a windows dialog that happens to appear that needs end user interaction or the document object never successfully reports back that the document is loaded then the document will never get into a loaded state so you will end up in a loop of waiting that will never end.
If there is a windows dialog that happens to appear that needs end user interaction or the document object never successfully reports back that the document is loaded then the document will never get into a loaded state so you will end up in a loop of waiting that will never end.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: GetDocument(Control) method is gone?
Thanks Ciege.
Already I have tried it. but I got same result.
In my code, webDoc is correct instance of Web Browser control.
hum..I don't know what I do next try..
Already I have tried it. but I got same result.
In my code, webDoc is correct instance of Web Browser control.
hum..I don't know what I do next try..
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: GetDocument(Control) method is gone?
Do you try to automate an application from the same application, i.e. automated and automating application are the same? That's usually not a problem as long as you do not use the GUI thread for automating, but a separate thread that executes the Ranorex code.
I guess you added the Ranorex automation code inside an event handler in your Windows Forms application, i.e. the code is executed on the same thread that updates the user interface of your application. That works until you invoke a Ranorex method that waits for some change in the user interface. That results in a deadlock since the GUI cannot change before the event handler method returns which is blocked by the call to the Ranorex method (in your case the WebDocument.Navigate method).
The solution to this problem is to use a separate thread that executes all the Ranorex automation code, i.e. instead of executing the code in your event handler directly, create a new thread the executes the same code:
Alex
Ranorex Support Team
I guess you added the Ranorex automation code inside an event handler in your Windows Forms application, i.e. the code is executed on the same thread that updates the user interface of your application. That works until you invoke a Ranorex method that waits for some change in the user interface. That results in a deadlock since the GUI cannot change before the event handler method returns which is blocked by the call to the Ranorex method (in your case the WebDocument.Navigate method).
The solution to this problem is to use a separate thread that executes all the Ranorex automation code, i.e. instead of executing the code in your event handler directly, create a new thread the executes the same code:
using System.Threading; // your event handler method private static void MyButton_Click(EventArgs e) { // next line is OK, since it is not a Ranorex method webBrowserControl1.Navigate("about:blank"); Thread thread = new Thread(new ThreadStart(RunAutomation)); thread.SetApartmentState(ApartmentState.STA); thread.Name = "RunAutomation"; thread.Start(); } // code in this method is executed on a separate thread private static void RunAutomation() { Form frmThis = "/form[@controlname='Form1']"; WebDocument webDoc = frmThis.FindDescendant<WebDocument>(); webDoc.Navigate("http://www.naver.com/"); webDoc.WaitForDocumentLoaded(); }Regards,
Alex
Ranorex Support Team