Hi
I am try to locate the googlesearch button using following lines.
//locate the first DOM and navigate to google
Ranorex.WebDocument doc=Host.Local.FindSingle("/dom[@childIndex='0']");
doc.Navigate("http://www.google.co.in",true,1000);
//Find the google search
//First Way
Ranorex.WebElement ele=doc.FindSingle("input[@Type='submit' and Value='Google Search']");
//Second Way
Ranorex.WebElement ele=doc.FindSingle("//input[@Type='submit' and Value='Google Search']");
ele.PerformClick();
In both cases the code fails because of this:
Ranorex.RxPathException: Parsing RxPath 'input[@Type='submit' and Value='Google Search']' failed:
line 1:25 no viable alternative at input 'Value'
can you tell me what is wrong here?
thanks
Ashish Abrol
finding the google search button
Re: finding the google search button
Attributes in the paths must start with @ 

- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: finding the google search button
Hi,
as mentioned before the "@" before the attribute "value" is missing.
For more details about the RanoreXPath have a look at following links:
http://www.ranorex.com/blog/ranorexpath-tips-and-tricks
http://www.ranorex.com/support/user-gui ... xpath.html
http://www.ranorex.com/support/screencasts.html
Regards,
Tobias
Support Team
as mentioned before the "@" before the attribute "value" is missing.
For more details about the RanoreXPath have a look at following links:
http://www.ranorex.com/blog/ranorexpath-tips-and-tricks
http://www.ranorex.com/support/user-gui ... xpath.html
http://www.ranorex.com/support/screencasts.html
Regards,
Tobias
Support Team
-
- Posts: 13
- Joined: Wed Feb 02, 2011 8:05 am
Re: finding the google search button
thanks sdaly. very nice! putting an @ before the attribute worked.
one thing more I would like to ask is about the time ranorex takes to locate the googlesearch button. It is quite substantial may be arnd 30sec.
here is the code
Ranorex.WebElement ele=doc.FindSingle("//input[@Type='submit' and @Value='Google Search']");
Ranorex.WebElement textele=doc.FindSingle("//input[@title='Search' and @type='text' and @name='q']");
textele.TagValue="ranorex";
ele.PerformClick();
would you know if the code could be made faster?
thanks
Ashish Abrol
one thing more I would like to ask is about the time ranorex takes to locate the googlesearch button. It is quite substantial may be arnd 30sec.
here is the code
Ranorex.WebElement ele=doc.FindSingle("//input[@Type='submit' and @Value='Google Search']");
Ranorex.WebElement textele=doc.FindSingle("//input[@title='Search' and @type='text' and @name='q']");
textele.TagValue="ranorex";
ele.PerformClick();
would you know if the code could be made faster?
thanks
Ashish Abrol
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: finding the google search button
Hi,
please have a look at the links I've just posted.
Especially RanoreXPath syntax examples which says:
Tobias
Support Team
please have a look at the links I've just posted.
Especially RanoreXPath syntax examples which says:
Regards,.//button: identifies all buttons that are descendants of the current element, i.e. all buttons in the subtree of the current element
Tobias
Support Team
-
- Posts: 13
- Joined: Wed Feb 02, 2011 8:05 am
Re: finding the google search button
Hi
I could not get .// to work. Here is my code.
Ranorex.WebDocument doc=Host.Local.FindSingle("/dom[@childIndex='0' and @BrowserName='IE']");
doc.Navigate("http://www.google.co.in",true,1000);
Ranorex.WebElement ele=doc.FindSingle(".//input[@Type='submit' and @Value='Google Search']");
Ranorex.WebElement textele=doc.FindSingle(".//input[@title='Search' and @type='text' and @name='q']");
textele.TagValue="ranorex";
ele.PerformClick();
error:
Ranorex.ElementNotFoundException: No element found for path './/input[@title='Search' and @type='text' and @name='q']' within 0ms.
Can you advice why this did not work?
thanks
Ashish Abrol
I could not get .// to work. Here is my code.
Ranorex.WebDocument doc=Host.Local.FindSingle("/dom[@childIndex='0' and @BrowserName='IE']");
doc.Navigate("http://www.google.co.in",true,1000);
Ranorex.WebElement ele=doc.FindSingle(".//input[@Type='submit' and @Value='Google Search']");
Ranorex.WebElement textele=doc.FindSingle(".//input[@title='Search' and @type='text' and @name='q']");
textele.TagValue="ranorex";
ele.PerformClick();
error:
Ranorex.ElementNotFoundException: No element found for path './/input[@title='Search' and @type='text' and @name='q']' within 0ms.
Can you advice why this did not work?
thanks
Ashish Abrol
-
- Posts: 13
- Joined: Wed Feb 02, 2011 8:05 am
Re: finding the google search button
I figured that page refresh caused by:
doc.Navigate("http://www.google.co.in",true,1000);
changes the childindex of the webpage(dom). Hence googlesearch button and textbox are never found by me.
If I remove the navigate.doc (above) and run the script on already open google page the script runs fine.
to counter this If I write my script as:
doc.Navigate("http://www.google.co.in",true,1000);
//make sure you are on the top page
Ranorex.WebDocument doc1=Host.Local.FindSingle("/dom[@childIndex='0' and @BrowserName='IE']");
Ranorex.WebElement ele=doc1.FindSingle(".//input[@Type='submit' and @Value='Google Search']");
Ranorex.WebElement textele=doc1.FindSingle(".//input[@title='Google Search' and @type='text' and @name='q']");
even this does not work...
can somone suggest me a solution?
Regards
Ashish Abrol
doc.Navigate("http://www.google.co.in",true,1000);
changes the childindex of the webpage(dom). Hence googlesearch button and textbox are never found by me.
If I remove the navigate.doc (above) and run the script on already open google page the script runs fine.
to counter this If I write my script as:
doc.Navigate("http://www.google.co.in",true,1000);
//make sure you are on the top page
Ranorex.WebDocument doc1=Host.Local.FindSingle("/dom[@childIndex='0' and @BrowserName='IE']");
Ranorex.WebElement ele=doc1.FindSingle(".//input[@Type='submit' and @Value='Google Search']");
Ranorex.WebElement textele=doc1.FindSingle(".//input[@title='Google Search' and @type='text' and @name='q']");
even this does not work...

can somone suggest me a solution?
Regards
Ashish Abrol
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: finding the google search button
Hi,
So your code should look something like this:
Tobias
Support Team
You have to increase the search timeout for the .FinsSingle method.error:
Ranorex.ElementNotFoundException: No element found for path './/input[@title='Search' and @type='text' and @name='q']' within 0ms.
So your code should look something like this:
Ranorex.WebDocument doc=Host.Local.FindSingle("/dom[@childIndex='0' and @BrowserName='IE']", 1000); doc.Navigate("http://www.google.co.in",true,1000); Ranorex.WebElement ele=doc.FindSingle(".//input[@Type='submit' and @Value='Google Search']", 1000); Ranorex.WebElement textele=doc.FindSingle(".//input[@title='Search' and @type='text' and @name='q']", 1000); textele.TagValue="ranorex"; ele.PerformClick();Regards,
Tobias
Support Team