I have the below code in html for a WebTable(Web Grid).
<table width="90%">
<div class="greybox" style="margin-top:2%;">
<table class="datagrid" width ="100%">....<table>
</div>
</table>
I tried providing exactly the same(all) properties in my descriptive programming but the Web Element(DIV) is not being identified by QTP. Is there a unique way to identify this?
Note: The Web page is developed a single page application
Edit:
So I think I have resolved the issue with the below code. There were two Objects being identified without the "Unique Text" if clause. First Object was parent of the DIV object so had to use a "Unique text" from the first object which wouldn't be part of any other object. I am currently trying with different data to see if it's working fine
Browsername = Browser("micClass:=Browser").GetROProperty("name")
Pagename = Browser("micClass:=Browser").Page("micClass:=Page").GetROProperty("name")
Set desc = Description.Create()
desc("micclass").Value = "Webelement"
Set ChildObject=Browser("name:="&BrowserName).Page("name:="&PageName).ChildObjects(desc)
Set Child_Table_Value = nothing
For i=0 to ChildObject.Count-1
innerhtmlvalue = ChildObject(i).GetRoproperty("innerhtml")
htmltag = ChildObject(i).GetRoproperty("micclass")
if(Instr(innerhtmlvalue, "MARGIN-TOP: 2%")<>0) then
if(Instr(innerhtmlvalue, "UniqueText")=0) then
if(Instr(htmltag, "WebElement")<>0) then
Set Child_Table_Value = ChildObject(i)
End If
End If
End IF
Next
Set Table_Value = Child_Table_Value.WebTable("html tag:=Table")
Ok, so assuming you have an HTML structure something like this:
<table width="90%">
<tr>
<td>
<div class="greybox" style="margin-top:2%;">
<table class="datagrid" width="100%">
<tr>
<td>UniqueText</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
...and as per your current solution you can rely on "UniqueText" being present, then you could try the following XPath statement:
(//table[contains(., 'UniqueText')])[last()]
So in QTP/UFT you'd be doing:
Browser("micClass:=Browser").Page("micClass:=Page").WebTable("xpath:=(//table[contains(., 'UniqueText')])[last()]")
Try to use like below.(Try to identify the div block using the "class")
Browser("micClass:=Browser").Page("micClass:=Page").Webelement("class:=greybox").Webtable("class:=datagrid")
Please let me know
Related
I am trying to access the table as well it rows and table data(td),generally the table,tr and td has no attributes to use I tried with index but still no use,even I tried with the parent element of table still I was unable to access it.
<div class = "Links"></div>
<div class = "board">
<table>
<tbody>
<tr><td>Name</td><td>Value</td></tr>
<tr><td>shaik</td><td>500</td></tr>
<tr><td>shahrukh</td>900<td><span style="" has css properties ></span></td></tr>
</tbody>
</table>
</div>
I tried in the following way
#ie.table(index,0) and
#ie.div(:class,'Links').table(:index,0)
returned an error as unable to locate the element
#ie.table by itself should work.
#ie.div(:class, 'Links') is not a parent of the table element since the </div> comes before the <table> in the dom.
Try this,
myelem = browser.tr(:text, /Name/).td(:index => 2).text
#or you can use the more user-friendly aliases for those tags
myelem = browser.row(:text, /Name/).cell(:index => 2).text
i am trying to add Element to existing html content using prototype insert. below is the html on which i am working
<table id="productGrid_table" class="data" cellspacing="0">
<thead>
<tr class="filter">
<th>
<div class="range">
</div>
</th>
</tr>
</thead>
here i want to add another < th> in < tr class="filter">, i am trying to achieve this using below prototype code
$('filter').insert("<th><div class='field-100'></div></th>");
please provide some suggestion what i am doing wrong here???
In PrototypeJS $('filter') selects element with id="filter". If you want to select by class, then use $$ function. Something like this:
$$('.filter')[0].insert("<th><div class='field-100'></div></th>");
But I'd recommend either changing class name to something more unique, or use id instead of class.
I have an odd problem whereby the model in my vbhtml file will correctly reference and bring up the model's attributes for 1 item but not for another.
FYI, The page is added as a partial page, connected to another vbhtml page.
My page is structured such that I want to list a number of people (beneficiaries), below each question (question text).
I am referencing my Model type using the syntax: #ModelType RHEAL_START.QuestionWithAnswers, so this should automatically allow the model items to be declared when instantiated.
The #ModelType declaration correctly allows the referencing of the 2nd model field (Model.benAnswers) but not the first one I have declared (Model.questionText).
Both items are part of the same model and, I have tried moving the declarations above and below the and headers but, this did not bring up an IntelliSense for the Model.questionText.
I looked at the following post and tried addding in a reference to the Layout file but alas, this did not bring up an IntelliSense either.
MVC3 - render view that is not a method in a controller
See the code below. Can anyone suggest where I'm going wrong and what else I can try?
If you need more information, please let me know.
#ModelType RHEAL_START.QuestionWithAnswers
#Code
Layout = "~/Views/MedicalQuestions/MedicalQuestions.vbhtml"
End Code
<div id="questionPanel">
#Code
Dim qAndARef As Integer = 0
End Code
<!-- Show question text and number -->
<h1>Model.questionText</h1>
<table>
<tr>
<td style="font-weight: bold">
Beneficiary </td>
<td style="font-weight: bold">
Yes/No </td>
<td style="font-weight: bold">
Details </td>
</tr>
<!-- !!Iterating over each beneficiary for Medical Question -->
#For Each benanswer As RHEAL_START.BeneficiaryAnswer In Model.benAnswers
Html.Partial("../MedicalQuestions/BeneficiaryAnswerPartial", benanswer)
Next
</table>
#*#Html.ValidationSummary()*#
</div>
#Section Scripts
#Scripts.Render("~/Scripts/RHEAL/YesNoDropDownValidation.js")
End Section
I'm not that familiar with the VB syntax for Razor, but it looks like you're missing a # sign in front of #Model.questionText
I have a partial view that I'm currently rendering and everything loads up nicely. I also have a #Html.Checkboxfor that iterates through a collection of items and enables a check for the controller when the value is 'True'. My problem is that the #Html.RenderPartial() seems to be unchecking all the values once it loads. I've checked the model and the values are there, if I remove #Html.RenderPartial() for my partial view then the #Html.CheckBoxFor() will display the checked values.
I'd like to ask the SO community if there is a fix for something like this as I've tried other solutions, but nothing seems to work.
Thanks in advance!
<fieldset>
<legend>Organization Access</legend>
<table>
<tr>
#{Html.RenderPartial("_OrganizationAccess");}
</tr>
</table>
</fieldset>
<fieldset>
<legend>Alerts</legend>
<table>
#for (var i = 0; i < Model.AlertMembership.Count; i++)
{
<tr>
<td>#Html.CheckBoxFor(p => p.AlertMembership[i].AlertStatus)</td>
<td>#Html.LabelForModel(Model.AlertMembership[i].AlertName)</td>
<td>#Html.HiddenFor(p => p.AlertMembership[i].AlertId)</td>
</tr>
}
</table>
</fieldset>
Found out what the problem was partial view's when rendered using (#HtmlRenderPartial("view here")) will load not only the content, but also affect the other DOM objects/attributes on the view page. I traced the problem down to an issue where the inputs where being checked to false. This is why the #Html.CheckBoxFor was showing 'false" for the checked attribute after the partial view rendered.
I have a four viewmodels/views which display similar but different data.
Is it possible to have a property on the viewmodel which retuns ActionLinks (or the html for them ?)
e.g.
At the moment on each of my Views I have
<table>
<tr>
<td>#Html.ActionLink("My Open Calls", "MyOpenCalls")</td>
<td>#Html.ActionLink("All Open Calls", "AllOpenCalls")</td>
<td>#Html.ActionLink("My Calls Today", "MyCallsToday")</td>
<td>#ViewBag.Title</td>
</tr>
</table>
but would it be possible to have:
<table>
<tr>
#Model.MenuHtml
</tr>
</table>
While it might be possible to store HTML in view models properties I don't think it would be a good idea. If you want to reuse some code why not simply put this table into a partial and then include the partial:
#Html.Partial("_Links")
Another possibility is to use a custom HTML helper that will generate those links.