Searching controls dynamically by adding search properties in code - coded-ui-tests

I am trying to identify controls at runtime by adding some search properties in my code as and when required. Using Coded UI in Visual Studio 2012.
Please refer to the screenshot below. My test scenario is:
1) Click on a particular tab (the 2nd tab selected in the screenshot)
The Tab list is fixed so I can create one control in My UIMap for each tab.
2) Inside every Tab, there is a tabular structure with some data. The Table headings are fixed but the number of rows and the data inside the rows is dynamic.
3) Check the checkBox for the required tag
4) Select Type for required tag
I have created my UIMap as:
Added following code:
UIEquipmentTagText.SearchProperties.Add(new PropertyExpression(WpfText.PropertyNames.Name, "1302"));// say I want second row
To fetch the respective checkbox control, I am using:
UITestControl UIEquipmentTagCell = UIEquipmentTagText.GetParent();//get the cell of Tag name
UITestControl UIEquipmentTagRow = UIEquipmentTagCell.GetParent();//get the row
UITestControl UIEquipmentCheckBoxCell = UIEquipmentTagRow.GetChildren()[0];//get the first cell i.e the checkbox cell
UITestControl UIEquipmentCheckBox = UIEquipmentCheckBoxCell.GetChildren()[0]; // get the checkbox control
But this is not working for me. I guess the UIRow control is referring to first row only (though I haven’t specified to look for 1st row)
I do not want to include row number in my search criteria for Row.
Is there any workaround to get all the controls I want based on the Tag Text only?

figured out a solution finally..get all rows and iterate to find the matching row
UITestControlCollection allRows = row.FindMatchingControls();
foreach (UITestControl x in allRows)
{
UITestControl Tag = x.GetChildren()[1].GetChildren()[0];//row->tag cell->tag text
if (Tag.GetProperty("Name").Equals("1302"))//say I want to select row having 1302 tag
{
UITestControl checkBox = Tag.GetParent().GetParent().GetChildren()[0].GetChildren()[0];//TagText->TagCell->Row->CheckBoxCell->Checkbox
Mouse.Click(checkBox);
}
}

Related

Set html table header as rpa collection header

Ive managed to get html table and change it to collection. However i would like for the table header to become the collection header. Is it possible to do it? Thanks.
Below is for further details on how i take the table element and change it to collection.
The path that im getting from the html table inside application modeller:
/HTML/BODY(1)/DIV(2)/FORM(2)/DIV(1)/TABLE(1)
Then i use Read stage and choose the table as the element and set Data as Get Table function and save the collection.
The collection result produces:
On header - Column1(text), Column2(text)....
First Row - Department, Name.... || This supposed to be the header
Second Row - DepartmentData, NameData....
Well, I got the action called "Set Column Names From First Row" in Utility - Collection Manipulation. Do you have it too?
If not, then here's the code:
Dim iThisColumn as integer = -1
For Each Column As DataColumn In Input_Collection.Columns
iThisColumn +=1
Column.ColumnName=CStr(Input_Collection.Rows.Item(0).Item(iThisColumn))
Next
Output_Collection = Input_Collection

Excel 2010: Merge and Concatenate Rows

I need help.
It seems all macros I stumble upon on this website require me to write out all the rows I'm concatenating and merging. I was wondering if I could do this with a while or if statement. In the meantime,
I need to merge a table of over 21000 names (more than half of which are duplicates) but each name duplicate either has data that the original is missing, or vice versa or sometimes has different data under each column and I need to merge them. There are also like 34 (up to AF) columns.
Thanks,
Eddie
P.S. Apparently I need at least 10 reputation to post images, so message me via my account name if you want a screenshot of what I'm looking for.
P.S.S.
So after consulting with someone who helped through a comment I wrote this java-based pseudocode. Could someone help me translate it to VBA while I start to learn VBA myself? Also could they verify that it theoretically works? I'd like to have this done by the end of the day, which is why I'm asking for translation help, but I'm planning to be able to do this on my own in the near future.
//Create primary keys for comparison, using the last cell as PK for easy line finishing
//Create concatenation comparison keys (conKey) to compare cells and merge
//import new sheet and create cell location to write to new sheet.
Create PK1 = (cell) AF1
Create PK2 = (cell) AF2
Create conKey1 = (cell) A1
Create conKey2 = (cell) A2
Create newSheet = [a new sheet]
Create writeLine = A1
//Initialize while loop. This list lasts until it reaches the last person's name
While(conKey2 <= maxClient) {
//Initialize the if statement. It finds out whether merge is necessary
If(PK1.equals(PK2)) {
//Initialize while loop. This lasts until PK1 no longer equals PK2
while(PK1.equals(PK2)) {
//Initialize if loop. It checks to see if the values are not equal. if so, it concatenates into conKey1
if(!conKey1.equals(conKey2)) {
conKey1 = concatenate(conKey1,", ",conKey2)
}
//Export cell to writeLine of newSheet. Shift everything to the right. verify writeLine equals conKey1
//Clear the doubled cell for safe keeping and to assist us in closing the while loop.
exportTo(newSheet.writeLine, conKey1)
conKey1.shiftsRight
writeLine.coordinates(equals(conKey1))
conKey2 = ""
conKey2.shiftsRight
}
//After this while loop is finished, delete the blank row.
//coordinates of PK1 and PK2 should remain the same at this point
deleteRow(PK2)
//If the merge was not necessary it will skip all of that above and shift each variable down a row.
} else {
PK1.nextRow
PK2.nextRow
conKey1.nextRow
conKey2.nextRow
writeLine.nextRow
}
If SQL is a solution and MAX value of all values is an accepted value... then using an ODBC, a defined table and a self reference may work..
Select Formulas then define name
Define the range of existing data
Select where you want the combined results to display (for example Sheet 2 (A1) instead of sheet 1)
Save the workbook
Select data then from other sources.
select data connection wizard
Select ODBC DSN
Select Excel Files
Find the file saved
Now select the new table (the one defined in step 1)
and complete the wizard.
Go to data menu
Properties
click connection properties button
select definition tab.
modify command text to fit needs
It takes data from sheet 1 such as this:
And provided the wizard is completed (steps 5-11) and then the SQL updated in step 16 you'll get something like
.
This is the command text I used. since it's SQL it can be altered to fit your needs max, concat, whatever
Select firstName, MiddleName, LastName, max(attrib1), max(attrib2), max(attrib3), max(attrib4)
From `yourPath&FileName.xlsx`.`YourDefinedName`
GROUP BY firstName, MiddleName, LastName

Filtering view in lotus notes

good day,
I'm trying to filter date by year using #setviewinfo. can anyone tell me how?
Here is an example, put this formula on PostOpen event on view. It will filter all document by column with user name.
#SetViewInfo([SetViewFilter]; #UserName; "columnName"; 1; 1)
columnName - is a real name of column (you may set it in Column Property)
Remember to clean filter on QueryClose even on view, otherwise all view will use this filter.
example how u should remove filter
#SetTargetFrame("frameName");
#UpdateFormulaContext;
#Command([OpenView]; #Subset(#ViewTitle; -1));
#SetViewInfo([SetViewFilter]; ""; "columnName"; 1)
frameName is a frame that contains view, columnName is your categorized column. If you do not use frame - simply skip 1-st row

How to add a field from a 2nd form?

I'm modifying an existing Lotus view to include a field from another form.
I first appended a new column and set it to the desired field. However, after I refreshed, the new column was blank even though I know it has data.
I then updated the View Selection formula from:
SELECT Form = "A" & StatusIndex < "06"
to:
SELECT (Form = "A"| Form = "B") & StatusIndex < "06"
Still no luck. The view is refreshing successfully, but the new field is still blank. What else is there to add this new column to this view?
This is my first time experimenting with Lotus, so if I seem to be missing some major concept, I probably am.
Edit
If I was pulling this data using SQL, the statement would probably be something like:
Select A.* , B.*
from A inner join B on A.id=B.id
where A.StatusIndex < "06";
Which brings up another question: Where is the relationship between these tables/forms defined?
Unfortunately, there is no (intrinsic) "join" functionality available from a Notes view. If you absolutely need the different columns appearing in the same row (document) in a view, then one option is to de-normalize the data, such that upon saving of "Document B" you update the related "Document A" with the necessary field values. (This is also the only real way to get full-text searches to work across "joined" data).
If the view is for display on browsers only, then you may have other options, such as making AJAX calls to load the related data fields, etc.
Here's a trick for adding multiple forms. This way you can easily add to the list of forms allowed without lots of OR statements.
#IsMember(Form; "A":"B") & StatusIndex < "06"
What I would try next, though, is to get rid of all conditions in your view and just show Form = "B", assuming the B form has the field you added in step 1. If that works, then you know it is just an issue with the view selection formula.
Also you can use the Document Properties to inspect document items. File > Document > Properties gets you there. I would triple-check that the documents that appear in that view do in fact have some data for the field in step 1.
Lastly, make sure the programmable name for the column in the view is unique. Double click the column header in the view designer, and then click on the last tab (beanie hat). The name that is there usually will be the same as the field you want to show in the column, or it will be a $number if the column value is a formula. You can change that name to something you know is unique just to be safe. The theory here is that if that programmatic name matches another column's programmatic name, then the view will not evaluate the column values and instead will used cached values, which in your case might be blanks. It's rare, but it does happen.
There is a simpler version of the 'multiple form' trick noted by Ken:
Select Form = "A":"B" & StatusIndex < "06"
or if you prefer:
Select (Form = "A":"B") & StatusIndex < "06"
This formula says: if (form = A or B) AND StatusIndex < "06"
Note: Be sure StatusIndex is Text (as you've quoted it) and the field StatusIndex with a value is included on both forms. If not, you need to fix your logic.
Plus: Documents display in a sorted or chronological order, ONE to a line, so you cannot have A & B data on a single line. It may look like:
A
A
A
B
B
B
OR
A
B
A
B
A
B
A
But never
A & B
A & B
A & B

How do I get the contents of a selected row from a YUI datatable?

I'm trying to get the contents of a cell in a row in a YUI datatable.
I can use myDataTable.getSelectRows()[0] to get the first selected row. However, how do I get the contents of the first cell in that row?
It looks like getSelectRows() returns an array of record IDs. You can retrieve the corresponding record using getRecord(). Once you have a record, use getData() to retrieve the value of the field you are interested in.
var recordID = myDataTable.getSelectRows()[0],
record = myDataTable.getRecord(recordID);
console.log(record.getData("myField"));
http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_getRecord
http://developer.yahoo.com/yui/docs/YAHOO.widget.Record.html#method_getData
I think I may have the answer for you assuming you have not already found it yourself.
I have the same kind of page with a datatable and a textarea field, when you select a row in the datatable calls the same page displays further detail from the selected row in the textarea field and retains selection of the selected row.
1: To do this I apply the following example MySQL query called AllMyBroadcasts...
SELECT #rownum :=#rownum + 1 RowNumber, p.*
FROM tblBroadcasts p, (SELECT #rownum := 0)r
ORDER BY Date DESC
the tblBroadcasts table has fields : Date, Narrative, ID
2: I then provide the following to the table row of my YUI Datatable within HTML hyperlink tags.
href="MyPage.php?SelectedBroadcastID=' .$row_Broadcasts['ID'].'&RowNumber=' .($row_Broadcasts['RowNumber'] -1 )
3: When the href is clicked MyPage reload with additional parameters SelectedBroadcastID and RowNumber the SelectedBroadcastID I use in a second query against tblBroadcasts called MySlectedBroadcast which a simple query on outputting all fields where the ID = SelectedbordcastID. I then to my field to display the narrative of my selected row in my textarea field.
The second paramater I do the following with.
$SelectedRowID = 0;
if( isset($_GET['RowNumber'])) {
$SelectedRowID = $_GET['RowNumber'];
}
Above I placed just after code covering my two queries.
4: Then finally to get the datatable to select the row of the selected row I include the following to the var yuidatdatable section of the datatable script...
yuidatatable1.select(yuidatatable1.getRow());
The -1 value referred to step 2 serves as a work around to fact that yuidatatable works on a 0 base and the MySQL referred to in step 1 on a 1 base.
There you go !
Perhaps there is a better why using get from within YUIDatatable scripting, be nice to know if so. That said this work fine for me and perhaps if you have not found an answer I hope this helps.

Resources