I am beginning with QTP and just cannot find out how to get value of element. For example when I just want to compare the number of results found by google. I tried to select the element with object spy and use Val(Element) to assign the value into variable..but it doesnt work. Could anyone help with this? BTW, I am not sure whether selecting the text (element) to compare with Object spy is correct.
Thanks!
You should use GetROProperty in order to get the text and then parse it for the value.
Looking at a Google results page I see that the result is in a paragraph with id=resultStats in the 3rd bold tag.
<p id="resultStats"> Results <b>1</b> - <b>10</b> of about
<b>2,920,000</b>
for <b>qtp</b>. (<b>0.22</b> seconds)</p>
So the following script gets the number (as a string with commas).
Browser("micclass:=Browser")
.Page("micclass:=Page")
.WebElement("html id:=resultStats")
.WebElement("html tag:=b","index:=2").GetROProperty("innertext")
Related
When i try to read values from a single cell in a tab using cypress it returns {specwindow: , chainerid: ch-https://app.trahop.com-218} instead of returning values inside the cell.
This is the line of code which returns the meesage above:
cy.log(cy.get("tr:nth-child(1) td:nth-child(1)")) .Im sorry if this is a stupid question but i cant find any way to read the values inside the cell.
cy.get() does not yield a text variable, but instead yields a Cypress-wrapped DOM element. In order to see the value, you'll need to include it in a chained Cypress command, or yield it into a .then() (or similar) Cypress statement.
cy.get('tr:nth-child(1) td:nth-child(1)')
.should('have.text', 'foo');
cy.get('tr:nth-child(1) td:nth-child(1)')
.then(($el) => {
cy.log($el.text());
});
I want to search for multiple codes appearing in a cell. There are so many codes that I'd like to write parts of the code in succeeding lines. For example, let's say I am looking for "^a11","^b12", "^c67$" or "^d13[[:blank:]]". I am using:
^a11|^b12|^c67$|^d13[[:blank:]]
This seems to work. Now, I tried:
^a11|^b12|
^c67$|^d13[[:blank:]]
That also seemed to work. However when I tried:
^a11|^b12|^c67$|
^d13[[:blank:]]
It did not count the last one.
Note that my code is wrapped into a function. So the above is an argument that I feed the function. I'm thinking that's the problem, but I still don't know why one truncation works while the other does not.
I realized the answer today. The problem is that since I am feeding the regex argument, it will count the next line in the succeeding code.
Thus, the code below was only "working" because ^c67$ is empty.
^a11|^b12|
^c67$|^d13[[:blank:]]
And the code below was not working because ^d13 is not empty but also this setup looks for (next line)^d13[[:blank:]] instead of just ^d13[[:blank:]]
^a11|^b12|^c67$|
^d13[[:blank:]]
So an inelegant fix is:
^a11|^b12|^c67$|
^nothinghere|^d13[[:blank:]]
This inserts a burner code that is empty which is affected by the line break.
I'm trying to format the output of an expression as a percentage to be shown in a table. With a normal cell, appmaker lets you select the dropdown to #formatNumber. I can't figure out how to do this with a longer expression:
#datasource.item.ROI_Percent * (365/(#datasource.item.Sale_Date - #datasource.item.PO_Date))
I've tried throwing the whole thing in parens and adding #formatNumber but that doesn't seem to work. Is there another function I'm missing? I want this to be a rounded percentage (704%)
Thanks
Once you break away from a single bound output, App Maker can no longer determine the result type and thus doesn't allow you to use their helper functions. You'll have to use plain old javascript.
Here's one way to format as a percentage:
(#datasource.item.ROI_Percent * (365/(#datasource.item.Sale_Date - #datasource.item.PO_Date))).toLocaleString("en", {style: "percent"})
I'm grabbing the following page and storing it in R with the following code:
gQuery <- getURL("https://www.google.com/#q=mcdimalds")
Within this, there's the following snippet of code
Showing results for</span> <a class="spell" href="/search?rlz=1C1CHZL_enUS743US743&q=mcdonalds&spell=1&sa=X&ved=0ahUKEwj9koqPx_TTAhUKLSYKHRWfDlYQvwUIIygA"><b><i>mcdonalds</i></b></a>
Everything other than "showing results for" and the italics tags encasing the desired name for extraction are subject to change from query to query.
What I want to do is extract the mcdonalds out of this string using regex that occurs here: <b><i>mcdonalds</i> aka the second instance of mcdonalds. However, I'm not too sure how to write the regex to do so.
Any help accomplishing this would be greatly appreciated. As always, please let me know if any additional information should be added to clarify the question.
In the line below, "ThenActivity" is an Assign activity nested inside the Then part of an If activity. Im trying to get at the expression, but this snippet isnt working.
((Assign)ThenActivity).To.Expression.ToString();
This returns "1.13: CSharpReference"
When it should read R = 44.5M, which is the expression text, how do I get at it?
The statement should read something like this
((CSharpValue)(((Assign)ThenActivity).Value.Expression)).ExpressionText
Note: You need to get the assignment, then its expression, cast that as a CSharpValue, then finally you can get the ExpressionText.