I need to run a javascript function of the web page from ranorex. So, I gave Add New Action -> User code and, I wrote the following code in Recording1.UserCode.cs
public void greet()
{
WebDocument webDocument = "/doc";
webDocument.ExecuteScript("document.write('Hello World!');");
}
When I play the recording I got the following error in report:
"No element found for path '/doc' within 10s."
What is missing? Or what is the right way to do it?
Thanks in advance
Ranorex Javascript ExecuteScript
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Ranorex Javascript ExecuteScript
Hello,
Your element with the path '/doc' could not be found.
Is it possible to track your element in Spy?
Please try to use the following path for your document:
Markus (T)
Your element with the path '/doc' could not be found.
Is it possible to track your element in Spy?
Please try to use the following path for your document:
WebDocument webDocument = @"/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']";Regards,
Markus (T)
Re: Ranorex Javascript ExecuteScript
Thanks for the response, Markus!
I tried with
WebDocument webDocument = @"/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']";
But still similar error.
This is what i did:
Ranorex studio->Recording(Exisiting recording where browser is opened and some mouse action)->Add new action->User code
In method-> greet
In Recording1.Usercode.cs
There was the function greet created in which I filled as follows:
Result:
No element found for path '/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']' within 10s.
Following is Recording1.Usercode.cs full code:
Is there anything I've missed out or not included or installed?
Thanks,
Lakshmi
I tried with
WebDocument webDocument = @"/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']";
But still similar error.
This is what i did:
Ranorex studio->Recording(Exisiting recording where browser is opened and some mouse action)->Add new action->User code
In method-> greet
In Recording1.Usercode.cs
There was the function greet created in which I filled as follows:
Code: Select all
public void greet()
{
WebDocument webDocument = @"/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']";
webDocument.ExecuteScript("document.write('Hello World!');");
}
No element found for path '/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']' within 10s.
Following is Recording1.Usercode.cs full code:
Code: Select all
///////////////////////////////////////////////////////////////////////////////
//
// This file was automatically generated by RANOREX.
// Your custom recording code should go in this file.
// The designer will only add methods to this file, so your custom code won't be overwritten.
// http://www.ranorex.com
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
namespace MyJavascriptCode
{
public partial class Recording1
{
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
private void Init()
{
// Your recording specific initialization code goes here.
}
public void greet()
{
WebDocument webDocument = @"/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']";
webDocument.ExecuteScript("document.write('Hello World!');");
}
}
}
Thanks,
Lakshmi
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Ranorex Javascript ExecuteScript
Hello,
Please make sure that the website is open in your browser.
Your code wouldn't open your website.
You might need to add the following code before:
Markus (T)
Please make sure that the website is open in your browser.
Your code wouldn't open your website.
You might need to add the following code before:
Host.Local.OpenBrowser("http://www.ranorex.com", "IE", "", false, false);Regards,
Markus (T)
Re: Ranorex Javascript ExecuteScript
Opening the browser is given in the recording. And while playing the recorded list, the browser is opened before executing the user code.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Ranorex Javascript ExecuteScript
Hi,
Just two questions, which Ranorex version are you using and which browser do you use?
Can you track the page with Spy tool and which RxPath is shown when you do so?
Regards,
Markus
Just two questions, which Ranorex version are you using and which browser do you use?
Can you track the page with Spy tool and which RxPath is shown when you do so?
Regards,
Markus
Re: Ranorex Javascript ExecuteScript
I was using the 30 days trial version.
Thanks for your response.
Thanks for your response.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Ranorex Javascript ExecuteScript
Hello,
It could be that the website http://ranorex.com instead of http://www.ranorex.com is opened.
This could be the cause for your issue since the domain object is different.
Regards,
Markus (T)
It could be that the website http://ranorex.com instead of http://www.ranorex.com is opened.
This could be the cause for your issue since the domain object is different.
Regards,
Markus (T)