Forum Discussion
Does the URL change in anyway. i.e. when navigating to a different page?
Do you use wildcards in your URL?
What lines of code are you commenting out, to make it work?
At the point I run into the issue, the URL does not change nor are wildcards being used. Here's an example of my code to hopefully give you an idea of what I'm seeing:
Lines a - b
/* Test does whatever */
// The below lines of codes are grabbing a value from a screen, splitting the colons, and saving the text after the third comma as 'recordNo'
Line 1 - var recordNoRowWhole = Aliases.browser.Page("www.google.com").ContentText.split(":");
Line 2 - var recordNoConverted = recordNoRowWhole.toString();
Line 3 - var s = recordNoConverted;
Line 4 - var i = s.indexOf(',', 1 + s.indexOf(',', 1 + s.indexOf(',')));
Line 5 - var recordNo = s.substring(i+1);
Line c - d
/* Test proceeds. I log out and then log back into the system. After I log in, I'm attempting to retrieve and access my record in a search screen using the recordNo variable. The lines below is something you actually helped me with in a previous post. */
Line 10 - var parameter = "//td[contains(., ' "+ recordNo.toString() + " ')]";
Line 11 - Aliases.browser.page.FindElement(parameter).Click();
When it gets to Line 11, the test fails. The log error states "Unable to find the object "//td[contains(., '1234')]".
When I re-test, I comment out Lines a - b, Lines 1 - 5, and Line c - d, and start the test from Line 10. I add another line before Line 10 re-defining my recordNo variable and directly setting it to the value I'm working with (since I commented out the lines that saved the value so I didn't have to run the entire script again). When I do this, the script works (I.E. clicks on the desired object). For example:
Line 9 - var recordNo = '1234';
Line 10 - var parameter = "//td[contains(., ' "+ recordNo.toString() + " ')]";
Line 11 - Aliases.browser.page.FindElement(parameter).Click();
Hope this gives you a better idea of the issue I'm running into. Again, thank you (and everyone else) for your time. It's really appreciated.
- Marsha_R2 years agoModerator
Make sure that recordNo is defined as a persistent variable. Otherwise the value is lost every time you log out.
- AMR0132 years agoContributor
Marsha_R ,
I did think my value was getting lost after logging out, so I printed out the recordNo value when I logged back in via Log.Message(recordNo) and the value persisted from when I first saved it earlier in the script.
Since I noticed my problem line worked if I commented out Lines a - b, Lines 1 - 5, and Line c - d and start the test from Line 10 as long as re-defined recordNo, I tried creating a new variable, recordNo2, setting it to the recordNo value, and then using recordNo2 for Line 10, but still doesn't recognize it.
Related Content
Recent Discussions
- 2 hours ago
- 6 days ago
- 10 days ago