Don't want to use repository only Ranorex Xpath

Ranorex Studio, Spy, Recorder, and Driver.
ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Don't want to use repository only Ranorex Xpath

Post by ngrishakin » Fri Oct 18, 2013 10:39 pm

I have the following example where I'm trying to enter my credentials to login page. This is the code I'm trying to use:
System.Diagnostics.Process.Start("firefox.exe", "http://qa02.com");
WebDocument webDocument = "/dom[@caption='Log On']";
WebElement userName = webDocument.FindSingle("/dom[@domain='qa02.crowdtor.ch']//input[#'UserName']", 5000);
userName.PressKeys("developer");

It successfully types user name into the field but I'm getting the following exception:

"Thrown: "Could not load file or assembly 'mscorlib.XmlSerializers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified." (System.IO.FileNotFoundException) Exception Message = "Could not load file or assembly 'mscorlib.XmlSerializers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.", Exception Type = "System.IO.FileNotFoundException"

I was trying to find good examples online but could not find a lot.
Can you please point me to the right direction.
Thanks,
Nikolay

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Don't want to use repository only Ranorex Xpath

Post by Support Team » Tue Oct 22, 2013 10:50 am

Hello,

It seems that the web document is not fully loaded.
Please try to add a 'WaitForDucumentLoaded()' method before you search for your input field.
You could try out the following code snippet:
System.Diagnostics.Process.Start("firefox.exe", "http://qa02.crowdtor.ch");
WebDocument webDocument = "/dom[@caption='Log On']";
webDocument.WaitForDocumentLoaded();
WebElement userName = webDocument.FindSingle("/dom[@domain='qa02.crowdtor.ch']//input[#'UserName']", 5000);userName.PressKeys("developer");
Regards,
Markus (T)

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Don't want to use repository only Ranorex Xpath

Post by ngrishakin » Mon Oct 28, 2013 10:28 pm

Marcus, there is no userName.Clear function to clean text box before typing in it. Can you let me know if there is an easy solution for this? PressKeys("{Delete} 20"); will delete 20 characters. But we don't know how many of them. Not very nice solution.
Thanks,
Nikolay

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

Re: Don't want to use repository only Ranorex Xpath

Post by krstcs » Wed Oct 30, 2013 1:33 pm

You could do the following:

Mouse.Click -> UserNameField
KeyShortcut -> "Ctrl-A" (Selects all text)
KeyShortcut -> "Del"
KeySequence -> $YourText
Shortcuts usually aren't...