I want a code to count the items for the stores that appear and the ability to show all the items to the last item and count them all.
I used the following code and it gives only one, I don't know what the problem is.
int I = driver.FindElements(By.XPath("//*[#id='QA0Szd']/div/div/div[1]/div[2]/div/div[1]/div/div/div[2]/div[1]")).Count();
MessageBox.Show(I.ToString());
I tried with every possible group vertex as shown in the red arrow and nothing gives only 1.
It is required to solve the problem or mention the error
Related
Is there a method of going about selecting items from a checked list box in coded ui when the exact text contained within the list box item will not be known until runtime? Perhaps a method of selecting a list box item at a certain index?..
I've tried using click list box at point (x,y) but whenever a list item is in its place it throws and error because it is in the way, And i cant try clicking the list box item itself as the full text it displays is a randomly generated ID and i am not sure if there is another method of finding items.
Another possibility would be passing in the text of the list box item to select at run time?
This is currently what I am trying to do in order to grab the control although it's throwing errors due to type mismatch
Managed to get it working with the following:
WinList uIItemList = UIMainwindowWindow.UIClbxSearchResultsWindow.UIClbxSearchResultsList;
WinCheckBox listItem = (WinCheckBox)uIItemList.Items[0];
listItem.Checked = true;
Just set the SelectedIndex property of the list box after its been populated. The below very simple example sets it to item 3 ( Zero based index)
lstBox.SelectedIndex = 2;
As per your comments, the same can still be achieved on checked list box with the below.
chkListBox.SelectedIndex = 2;
chkListBox.SetItemCheckState(2, CheckState.Checked);
Hope that helps.
I'm having trouble trying to figure out why accessing row 0, col 3 on an HTML table isn't working. I'm using C# and Visual Studio.
While debugging if we let it pass by once and then set it back to the same line that grabs it as a variable then it would work. But never the first time through, if I went for row 1, col 3, being the next cell down one, it would grab it fine and so on with any others except for row 1 (being index 0).
Segments of the code are as follows, but we couldn't figure out why it wasn't working on specifically the first row, we even tried adding a delay to make sure the page was fully loaded and still wasn't returning any value. To remind you, it worked on every row but the first, even when the item in the first row was changed. The item in the first row, fourth col will always be changing so there is no specific class or identifier I can just access it by every time.
Any clue why it's not working for the first row and any fixes would be greatly appreciated. I have a work around, but it would just be easier to do it like this:
using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
var browser = BrowserWindow.Launch("https://blah.com/");
var cell = GetCell(browser, 2, 3);
Console.WriteLine(cell.Value.ToString());
HtmlCell GetCell(UITestControl parent, int row, int column)
{
var cell = new HtmlCell(parent);
cell.SearchProperties.Add(HtmlCell.PropertyNames.RowIndex, row.ToString());
cell.SearchProperties.Add(HtmlCell.PropertyNames.ColumnIndex, column.ToString());
return cell;
}
Allen,
You may want to make sure that the header row of your table is of the same form as the remaining rows.
You are correct that row indexes start at 0.
You may want to try creating a debugging method. Remember that a cell is a child of a row. Pass in a table as a ui parent object and iterate through each row, then iterate through each cell and see what the debugger is showing you as values for these objects (including their types).
My suspicion is it'll be something to do with the header structure or that a element has a different object type than rather than HtmlCell
I have a listview which has 7 columns. I want to add information on each column, but when it reaches the subitem 2 from the listView I get a System.ArgumentOutOfRangeException even though I have that subitem.
Any idea why I get this error? I've tried to search for it but I haven't found a similar case.
This is the part of the code where I get that error:
if (seen == true)
listView1.SelectedItems[0].SubItems[2].Tag = "Seen";
else
listView1.SelectedItems[0].SubItems[2].Tag = "Not Seen";
You probably do not have all those SubItems in each item.
Or maybe nothing is selected? (Note that the SelectionChanged event gets called when an Item is unselected as well!)
Note that every Item in a ListView can have its own number of SubItems, no matter how many Columns you have created. These only provide a space to display the data, not slots you can access without creating SubItems !
Therefore we must test it before we access it! In other words: The ListView structure is not a 2d array but a jagged array!
This could be a possible check..:
if ( listView1.SelectedItems[0].Count > 0 &&
listView1.SelectedItems[0].SubItems.Count > 2 )
listView1.SelectedItems[0].SubItems[2].Tag = seen ? "Seen" : "Not Seen";
..but you know your code better and may well find a nicer way of doing the necessary tests..
Just do not rely on the number of SubItems being equal to the number of Columns. They are not related at all and either may be greater in each Item!
I am having a problem getting a coded UI test to select the correct item in a grid. I record the whole thing slowly and save the recording. While I am recording, one of the tasks it to select item D in a grid.
When I play back the recorded test, it selects item A or sometimes item B when it gets to the grid. This ends up throwing the whole test off.
Why is this happening? Is the test not recording properly? Is there anything that can be done to resolve this?
Thanks
This is due to following reasons:
While you record, the row place is different with respect to play back;
It always identify with the dynamic row ID and it will try to search for the same.
Solution: you can use descriptive way of coding in order to handle GRID.
Identify the grid and get the row with respect to unique text in that row and do the necessary action.
I'm pretty much to C# and I'm trying to create a simple network analyzer. I want to be able to see packets in a datagridview. The imagined lay-out can be compared with tools like wireshark. I would like my datagridview to always be "filled". By filled I mean that it always contains rows even if these are empty.
When starting the application for example I would like the grid to be fully filled with rows. The total height of the gridView is a multiple of the row height, so it contains enough rows so it's exactly 100% filled. When adding data however I would like that these empty rows do not count so data overwrites these empty rows, and when removed these rows return if otherwise the DataGridView would not be fully filled. I realize I might explain this a bit poorly but I'm not sure how I could try to bring across what I mean otherwise. The way Excel works would be ideal for example. You start with a full screen with empty cells, and you can add things to them. If you add more data than fits a scoll bar gets introduced to still be able to see all data. When you remove it the scrollbar becomes smaller until eventually it's not needed anymore but the cells remain shown. (even if empty)
Thanks in advance,
Arnold
-edit-
Regarding height of things: I'd probably want things to be resizable in the future. So that information could probably not be exploited.
Wrap a DataGridView with a user control to override adding and removing rows.
If you are removing a row - it must be real (not marked as "place holder" [tag?]).
and if your Count is less than IdealCount, add a "place holder" row.
If you are adding a row - if your Count is less than IdealCount, remove the last "place holder" row.
Initialize with IdealCount number of "place holder" rows.
Let the rows be sorted by a hidden column of default value 0 and a value of 1 for "place holders" or simply maintain the rows order yourself in the Add override. This way the "place holders" will always be last (and there won't be any, if Count > IdealCount).