
Full image shown here.
The XPath for the link title is:
Code: Select all
/tooltip[@text='link title']
Thanks!
Code: Select all
/tooltip[@text='link title']
I'm using Ranorex V 5.2.020272, Windows 7 and Firefox 33.1.1.Attribute 'Text' of element for item 'Z_Ranorex_Web_Testing_ExampleRepository.LinkTitle.Self' does not match the specified value (Failed to find item 'Z_Ranorex_Web_Testing_ExampleRepository.LinkTitle.Self'. No element found for path '/tooltip[@text='link title']' within 30s.).
How do I create the repo item for Firefox, given that I can't seem to get Spy to identify the tooltip? Or to put my question another way...krstcs wrote:Create two repo items, one for FF....
What would the XPath be for that?Support Team wrote:...
Code: Select all
/tooltip[@text='link title']
My test looks like this:Element for item 'Tooltip_in_Firefox' does not exist (Failed to find item 'Z_Ranorex_Web_Testing_ExampleRepository.Tooltip_in_Firefox'. No element found for path '/tooltip[@text='link title']' within 30s.).
Therefore, the RxPath is the following:
Code: Select all
/form[@title='YourTitle']/tooltip[@accessiblename='link title']
Code: Select all
/form/tooltip[@accessiblename='link title' and @visible='True']
I've done all of that and have a method in the code module that looks like this;krstcs wrote:Create two repo items, one for FF, the other for the rest.
In user code, do an if-then-else:
if (browser==FF) check the ff tooltip repo item...
else check the main tooltip item
EDIT: The easiest way to do it is to drop BOTH validations into the same recording module, one after the other. Select both lines and right-click. Select "Merge to User-code". Double-click the new "User-code" line and it will open up the editor. Just wrap the two actions (2 lines each) with the if and else, making sure to have the logic correct.
Code: Select all
public void MergedUserCodeMethod()
{
Report.Log(ReportLevel.Info, "Validation", "Validating Exists on item 'Tooltip_in_Firefox'.", repo.Tooltip_in_FirefoxInfo);
Validate.Exists(repo.Tooltip_in_FirefoxInfo);
Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (Visible='True') on item 'LinkTitle'.", repo.LinkTitle.SelfInfo);
Validate.Attribute(repo.LinkTitle.SelfInfo, "Visible", "True");
}
Code: Select all
if(browser == Firefox) {
Report.Log(ReportLevel.Info, "Validation", "Validating Exists on item 'Tooltip_in_Firefox'.", repo.Tooltip_in_FirefoxInfo);
Validate.Exists(repo.Tooltip_in_FirefoxInfo);
} else {
Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (Visible='True') on item 'LinkTitle'.", repo.LinkTitle.SelfInfo);
Validate.Attribute(repo.LinkTitle.SelfInfo, "Visible", "True");
}
Code: Select all
if (browser == "Firefox") {
//do stuff for FF here
} else {
//do stuff for everything else here
}
Yes, the "$" was added by Ranorex not by me.Also, you shouldn't use '$' in variable names in .NET. This is just what Ranorex uses in its domain specific language to signify a user variable in the front-end.
I've made that change, but my code, copied below, still isn't working. It seems to be an issue with the word "browser" in the if condition?The browser name is stored as a string, so you have to work with it as a string... "Firefox".
Code: Select all
if(browser == "Firefox") {
Report.Log(ReportLevel.Info, "Validation", "Validating Exists on item 'Tooltip_in_Firefox'.", repo.Tooltip_in_FirefoxInfo);
Validate.Exists(repo.Tooltip_in_FirefoxInfo);
} else {
Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (Visible='True') on item 'LinkTitle'.", repo.LinkTitle.SelfInfo);
Validate.Attribute(repo.LinkTitle.SelfInfo, "Visible", "True");
} // else
Code: Select all
string browser = repo.MyDomObject.Self.Browser;
if (browser == "Firefox") {...}
//or, the more efficient way, not instantiating an unnecessary object (string browser)...
if (repo.MyDomObject.Self.Browser == "Firefox") {...}