Micro Focus QTP (UFT) Forums
How to get text of weblement - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to get text of weblement (/Thread-How-to-get-text-of-weblement)

Pages: 1 2


How to get text of weblement - sudhirzpatil - 12-15-2010

Hi All,

On Mercury Tours web application, when we Select Departing From, Arriving In City and continue on next page, it displayed both City as text element.
For example if we select 'Paris' in Departing from and 'London' in Arriving in drop down the text displayed on next page is like this 'Paris to London'

Using getroproperty("innertext") i am able to get that that particular text.

But i want to verify it for different City selected in Departing from and Arriving In.
i.e. if I parametrize both Departing from and Arriving In drop down I want to verify the text on next page.
Can any one please me guide on this ?

Thanks in advance

Sudhir


RE: How to get text of weblement - manishbhalshankar - 12-16-2010

Hi Sudhir,

You can do that by using GetROProperty("innertext") itself. But make sure you are not using innertext property for object identification. Try using some other unique properties and if not you will have to parametrize this property or use regular expresstion.


RE: How to get text of weblement - sudhirzpatil - 12-16-2010

Hi Manish,

I tried with other only available property html tag= Font. The problem here is that the required text is web element whose name is also same as innertext property value.

I have attached object hierachy for referance.

On parameterize and using regular expression how we can verify the required text on next page ?

Thanks in advance.


RE: How to get text of weblement - manishbhalshankar - 12-17-2010

In datatable add a column "FlightDetails". In this column add all the text to be verified, e.g. "Frankfurt to Paris".
No parameterize your webelement and checkpoint to take the name/innertext from this column.
All the combinations should be given on different rows. In the begening of For loop mention: DataTable.SetCurrentRow(i).
i is the loop counter.


RE: How to get text of weblement - sudhirzpatil - 12-18-2010

Hi Manish,

I have parameterze the Fly From and Fly TO for different City.
It works for first parameter.But when it comes to second parameter it displayed following error message.

The test run cannot continue due to an unrecoverable error.

Cannot identify the object "Frankfurt to New York" (of class WebElement). Verify that this object's properties match an object currently displayed in your application.

Line (8):
Code:
"Browser("Welcome: Mercury Tours").Page("Select a Flight: Mercury").WebElement("Frankfurt to New York").Check CheckPoint("Frankfurt to New York")".

The problem here is that the webelement("Frankfurt to New York"),changes as Fly From and Fly To get chnaged.

Will you please guide me how to use regular expression for this WebElement("Frankfurt to New York") ?


RE: How to get text of weblement - manishbhalshankar - 12-20-2010

Hi Sudhir,

You will have to parameterize both, the WebElement as well as the Checkpoint from datatable.


RE: How to get text of weblement - sudhirzpatil - 12-20-2010

Hi Manish,

I am able to solve it partialy. I used Standard checkpoint to get the required text.
I used following For loop.

Code:
for i=1 to Datatable.rowcount
set Datatable.currentrow
msgbox Datatable.value("Datatable column Name",dtGlobalSheet)
Next

Here i am getting the expected value. I have set the Run properties to Run for all iteration.
But here it runs 9 times.
On first iteration it displayed the expected value. then for second and third the msgbox is blank.
Again for fourth iteration it displayed the expected value of Second parameter i add for Fly From and Fly To. Fifth, sixth are again blank. so on...
Is there anything wrong with For....Next loop ?


RE: How to get text of weblement - manishbhalshankar - 12-20-2010

Hi Sudhir,

Change the run Properties to Run one Iteration Only.
Now update For loop as:
Code:
For i = 1 To DataTable.GetRowCount
   DataTable.SetCurrentRow(i)
   MsgBox DataTable.Value("DataTable Column Name", dtGlobalSheet)
Next



RE: How to get text of weblement - sudhirzpatil - 12-20-2010

Thanks very much Manish, for your prompt reply. I will try on it.
One Question related to this thread, what is regular expression pattern to match ' Paris to London'. Here only 'to' remains constant.


RE: How to get text of weblement - manishbhalshankar - 12-20-2010

Hi Sudhir,

The Regular Expression will be:
.* to .*
But this wont be able to check if the values are getting populated as per your selection on previous page rather it will consider any text before and after "to".