How do i scroll a UITable view down until i see a cell with label "Value" in Calabash - iphone

How do i scroll a UITableView down until i see a cell with label "Value" in Calabash/Cucumber.
I've been trying to do it using:
Then I swipe down until I see "Value"
and using:
Then I scroll down until I see "Value"
but none of them seem to work. Thanks!
The message I get when I try with the above is obviously:
You can implement step definitions for undefined steps with these
snippets:
Then(/^I swipe down until I see "(.*?)"$/) do |arg1| pending #
express the regexp above with the code you wish you had end

add step definitions
Then /^I scroll to cell with "([^\"]*)" label$/ do |name|
wait_poll(:until_exists => "label text:'#{name}'", :timeout => 20) do
scroll("tableView", :down)
end
end
to the ProjectName/features/step_definitions/my_first_steps.rb ruby file and
In your calabash script add
Then I scroll to cell with "AAA" label
its working fine for me.

Every cucumber framework has a set of predefined steps. Of course, these steps don't cover all the possibilites. If you need additional functionality, you have to define your own steps:
When /^I scroll (up|down) until I see "([^\"]*)"$/ do |direction, something_to_see|
#implement the step here
end
I can't help you with the exact implementation (what is "Value"?) but you can find the core functions here
Probably you'll need function
scroll(uiquery, direction)
(where uiquery will be tableView)
If you take this function and element_is_not_hidden you can create a while cycle which will scroll down until you see the "Value".
Maybe something similar to the following (I don't know Calabash but I know Frank a little)
When /^I scroll (up|down) until I see "([^\"]*)"$/ do |direction, something_to_see|
max_scroll_tries = 10
[0..max_scroll_tries].each do
break if element_is_not_hidden("view marked:'#{something_to_see}'")
scroll("tableView", direction)
end
check_element_exists_and_is_visible("view marked:'#{something_to_see}'")
end

table have rows and sections, based how your code is organized use rows or sections in below code
def scroll_side_panel(text)
section=0
scroll_to_cell(:row => 0, :section => 0) # scroll to top of view
sleep 1 # wait for a second
#Scroll to each element and compare text, if there is a match break
each_cell(:animate => false, :post_scroll => 0.2) do |row, sec|
puts "#{query("tableViewCell indexPath:#{row},#{sec} label", :text)} #{text}"
if query("tableViewCell indexPath:#{row},#{sec} label", :text).first==text
break
end
section=section+1
end
puts "table view text found at element number:#{section}"
end

following should also work
Then(/^I scrolldown until "(.*?)" is visible$/) do |arg1|
until query("lable text:'#{arg1}'").length > 0
scroll("tableView", :down)
end
end
Call this by following
Then I scrolldown until "XY" is visible

Related

Unmerge and Assign Values Only Vertically or Horizontally Openpyxl

Using the answer provided by aka863 here: How to split merged Excel cells with Python?
I can unmerge, fill values and copy the styling. My questions is how to make the value assigning/filling process configurable.
I want the user to be able to choose whether the values will be filled vertically/horizontally.
I have tried changing the last loop where we assign the top_left_cell_values to unmerged cells. However I couldn't find a way to make it horizontal/vertical configurable. (I'm planning to use radio buttons and tkinter for this)
Its certainly possible to have the code de-merge cells and fill cells in whichever direction, vertically or horizontally regardless of which way the merge was originally. Or not fill at all, so only the top left cell retains the 'value' of the previously merged cells, which is default on unmerge.
Changing the direction of the fill requires some change and re-calculation on the max row and column values in the iter_rows loop, but is simple enough.
However it seems in your last comment you just want to give the user the option to fill or not fill on horizontal merges. In that case you just need to ask the question, and then run the iter_rows loop only if the response is yes.
The code sample below is based on the answer referenced question.
I'm assuming only single line horizontal merges since you dont mention what if anything should be done with vertical merges in the comment.
The code does initially check and indicate the merge direction either vertically or horizontally so it can be included take some action if a merge is vertical.
On code run after displaying the range and direction of the merge, the question is asked to fill, yes or no. If yes the cells are de-merged and all cells filled with the top left cell value using the iter_rows loop. If answer no then the cells are just de-merged.
from openpyxl import load_workbook
from openpyxl.utils.cell import range_boundaries
wb = load_workbook(filename='foo.xlsx')
st = wb['Sheet1']
mcr_coord_list = [mcr.coord for mcr in st.merged_cells.ranges]
direction_dict = {'v': 'vertical', 'h': 'horizontal'}
for mcr in mcr_coord_list:
print('---------------------------------------------------\n')
merge_direction = ''
min_col, min_row, max_col, max_row = range_boundaries(mcr)
top_left_cell_value = st.cell(row=min_row, column=min_col).value
if min_col == max_col:
merge_direction = 'v'
elif min_row == max_row:
merge_direction = 'h'
print(f"The cell range {mcr} is merged {direction_dict[merge_direction]}ly with the data '{top_left_cell_value}'")
while True:
demerge_fill = input('Do you want the de-merge to fill all cells(y|n)? ')
if demerge_fill.lower() in ["y", "n"]:
break
else:
print('Invalid response')
st.unmerge_cells(mcr)
if demerge_fill == 'y':
for row in st.iter_rows(min_col=min_col, min_row=min_row, max_col=max_col, max_row=max_row):
for cell in row:
cell.value = top_left_cell_value
else:
print(f"Only the top left cell {mcr.split(':')[0]} will contain the data!")
wb.save('merged_tmp.xlsx')

How to change background color for each two rows in SSRS in a group

How can I write the expression in order to change background color for each two rows in SSRS?
I need something like that:
I tried expression
=IIF(Fields!Type.Value="2016 Submitted" , "LightBlue",
IIF(Fields!Type.Value="2015 Submitted" , "LightBlue",
Nothing))
But because some months dont have values it looks like this:
If I try this expression I get below:
=IIF(RunningValue(Fields!Count.Value, CountDistinct, Nothing) MOD 2 = 1, "White", "PaleTurquoise")
Dance-Henry I tried your code
=IIF(RowNumber(Nothing) Mod 4 = 1 or RowNumber(Nothing) Mod 4 = 2, "Aqua","White")
and this is what i got:
You can select the row in design pane and press F4 to setup property BackgroundColor as =IIF(RowNumber(Nothing) Mod 4 = 1 or RowNumber(Nothing) Mod 4 = 2, "Aqua","White")
Captures are attached. Do it accordingly.
RESULT is something like this
After going thru the link https://blogs.msdn.microsoft.com/chrishays/2004/08/30/green-bar-matrix/
Tested and it works well for the Green Bar Effect for Matrix. I will show it step by step here as for later reference.
Step 1: Create the Matrix and add one more column under the innermost row grouping in your matrix. (ColorNameTextbox here)
Step 2: Select the textbox of ColorNameTextbox and press F4 to setup BackgroundColor property as =Value shown below.
Step 3: Select the textbox of Matrix cell and press F4 to setup BackgroundColor property as =ReportItems!ColorNameTextbox.Value shown below.
Step 4: Drag the inner grouping header (ColorNameTextbox) to be as narrow as possible.
Step 5: Preview Pane to check the result.
If you could add a hidden color_group column and populate it with a new number at each point you want to change the color (in your case 1,1,2,2,3,3,4,4) then you could use something like the following (which works for varying size groups):
IIF(RunningValue(Fields!color_group.Value, CountDistinct, Nothing) MOD 2 = 1, "White", "PaleTurquoise")
I had a similar problem where I could not come up with alternating rows because my data has Column Groups that were the RowNumber(Nothing) method to fail. Learning from all the other posts here this is how I resolved it in steps.
I added the following code into the report properties, that provides a function to get the row number, each time it is called. The function increments the row count each time it is called. >>Right click space around the report >> Properties >> Code. Alternatively go to Code Properties Window, when the report is selected.
Add the following lines:
Public Row_Sum As Decimal = 0
Public Function Lookup_Sum( ) As integer
Row_Sum = Row_Sum + 1
Return Row_Sum
End Function
I added a new column at the beginning of the rows called No. that would calculate and show the row number.Right click the first column >>Insert Column>>Inside Group-Left.
On the expression for the new report add this line of code. Also take a note of the name of the TextBox that will have the No. Value. It will be needed in the next step. In my case the TextBox is called TextBox6 (Properties Window). >>Right Click Cell>>Expression.
Add the code:
=Code.Lookup_Sum()
I highlighted the entire row and went to the Background property and added the following expression to compute the row number.
Add the code(TextBox6 is the name Textbox name noted above):
=IIF(VAL(ReportItems!Textbox6.Value) MOD 2, "LIGHTBLUE", "WHITE")

using popupmenu in uitable in matlab

I have created a uitable consists of, say, four columns.
colu={{'Sweet' 'Beautiful' 'Caring'},'numeric', 'numeric','numeric'}
dat={1 2 3 []; 4 5 6 []; 7 8 9 []};
A=uitable('outerposition',[0 0 1 1],'ColumnFormat',colu,'Data',dat);
What I wanted to do now is that when the code is run, and I choose 'Sweet' in the pop-up in the first cell, the cell (1,4) displays dat(1,1), or when I choose 'Beautiful' in the second cell in the first column, the cell (2,4) displays dat(2,1). Unlike in a popupmenu outside a uitable, I am not able to use get(popup,"value').
How could I possibly do what I wanted to? Thanks in advance!
You'll have to use the CellEditCallback property, which is a global callback that gets triggered when any cell is edited.
There are no callbacks you can set on individual cells.
A pseudo-code template that should get you started:
function cellEditCallback(hTable, editEvent)
% get changed index
changedIndex = editEvent.Indices;
if changedIndex is a popup-cell:
% check new value
newValue = editEvent.NewData;
% set data in appropriate cell to corresponding value
...
As an aside, the columnFormat in the example does not match the data. It specifies column 1 as a popup-column, while according to your data, it should be column 4.
I also had to change [] to '' to make the popup work and set('ColumnEditable', logical([0,0,0,1])).
See e.g.
http://www.mathworks.de/products/matlab/examples.html?file=/products/demos/shipping/matlab/uitabledemo.html
for a more comprehensive example uitable application.

Table cells to be edited only on double click

The table cell is edit with a simple click, I want it to be edit only on double click. Simple click will select the cell.
I'm use this property of uitable:
set(hTable, 'Data',data,...
'ColumnEditable', edit,...
First you need to set the cell editabiliy to false by default:
set(hTable,'ColumnEditable', [false false ...]); %accordingly your number of columns
and introduce a CellSelectionCallback:
set(hTable,'CellSelectionCallback',#cellSelect);
which calls the following function within the same script
function cellSelect(src,evt)
getstate = get(src,'ColumnEditable'); %gets status of editability
index = evt.Indices; %index of clicked cell
state = [false false ...]; %set all cells to default: not editable
state(index) = ~getstate(index); %except the clicked one, was it
%already false before set it true
set(src,'ColumnEditable', state) %pass property to table
end
and also a CellEditCallback:
set(hTable,'CellEditCallback',#cellEdit);
calling
function cellEdit(src,~)
state = [false false ...];
set(src,'ColumnEditable', state)
end
minimal example
function minimalTable
h = figure('Position',[600 400 402 100],'numbertitle','off','MenuBar','none');
defaultData = {'insert number...' , 'insert number...'};
uitable(h,'Units','normalized','Position',[0 0 1 1],...
'Data', defaultData,...
'ColumnName', [],'RowName',[],...
'ColumnWidth', {200 200},...
'ColumnEditable', [false false],...
'ColumnFormat', {'numeric' , 'numeric'},...
'CellSelectionCallback',#cellSelect);
end
function cellSelect(src,evt)
getstate = get(src,'ColumnEditable');
index = evt.Indices;
state = [false false];
state(index) = ~getstate(index);
set(src,'ColumnEditable', state)
end
function cellEdit(src,~)
state = [false false];
set(src,'ColumnEditable', state)
end
As you figured out this is not always working. Because you have the same issues like I had before with popup menus. It's exactly the same problem: ColumnEditable is just a row vector and not a matrix. I had to deal with the ColumnFormat property, which is also just a row vector. If the double click feature is really important to you, you can consult the following two answers:
Is it possible to prevent an uitable popup menu from popping up? Or: How to get a callback by clicking a cell, returning the row & column index?
How to deselect cells in uitable / how to disable cell selection highlighting?
The threads basically suggest to create a unique uitable for every single row, so that every single row has a unique ColumnEditable property. That's the only solution so far.
I'm afraid there is no simple solution. I can't offer you further help, except the complicated workarounds of the other answers. Or just use the simple one above and live with the little drawbacks.
Although this thread is old but in my opinion still valuable to some users.
I have tested the following with R2010b 32bit.
I have achieved editing only on double click simply by setting
set(hTable,'CellSelectionCallback',#tableCellSelectCB,'ColumnEditable',true)
and defining its function the following
function tableCellSelectCB(~,~)
try
h.jtable.getCellEditor().stopCellEditing();
catch
end
end
where h.jtable refers to the underlying java object of your uitable.
This way, I can select even single and multiple cells, without going into edit mode. On a double click on a single cells lets me edit its contents.
Extension to have individual editable rows
I wanted to have checkboxes in the top row and non-editable (not directly at least) data in the rest of the table. You can easily modify the above:
function tableCellSelectCB(~,evd)
if evd.Indices(1) > 1
try
h.jtable.getCellEditor().stopCellEditing();
catch
end
end
end

Setting up some properties for a combobox (scroll, edit, jump)

There are 3 properties that I want to set for some VBA form comboboxes and I don't know if it's possible.
I don't want to let the combobox editable. Right now if the user types something in it that it submits the form it will send that value... I want to let him choose only from the values I added in the Combobox.
I want to make the list of items in the combobox scroll-able. Right now I'm able to scroll through the list if I use the scroll-bar but I don't know why I can't scroll with the mouse scroll.
And I want to jump to some item if I start typing. Let's say I have the months of the year in one combobox... if I start to type mar I want it to jump to march. I know that for the html forms this properties is by default but I don't know about VBA forms...
Thanks a lot
Of the behaviours you want, some are possible with settings on the Combo, others you will need to code
List of Months: Put a list of entries on a (hidden) sheet and name the range. Set .RowSource to that range
Match as you type: Set properties .MatchEntry = fmMatchEntryComplete and .MatchRequired = True
Reject non list entries: A Combo with these settings will allow you to type an invalid entry, but will reject it with an error message popup when you commit. If you want to silently reject invalid data as you type, you will need to code it.
If you want the selected value returned to a sheet, set .ControlSource to a cell address (preferable a named range)
By "...scroll with the mouse scroll..." I assume you mean the mouse wheel. Unfortunatley Forms don't support mouse wheel scroll. You will have to code it yourself. There is a Microsoft patch for this at here (not tried it myself yet)
Sample code to silently reject invalid entries
Private Sub cmbMonth_Change()
Static idx As Long
Dim Match As Boolean
Dim i As Long
If cmbMonth.Value = "" Then Exit Sub
If idx = 0 Then idx = 1
i = idx
Match = False
For i = 0 To cmbMonth.ListCount
If cmbMonth.List((i + idx - 1) Mod cmbMonth.ListCount) Like cmbMonth.Value & "*" Then
cmbMonth.ListIndex = (i + idx - 1) Mod cmbMonth.ListCount
Match = True
Exit For
End If
Next
If Not Match Then
cmbMonth.Value = Left(cmbMonth.Value, Len(cmbMonth.Value) - 1)
End If
End Sub
Set the propertie MatchEntry of combobox to 1 (fmMatchEntryComplete) and MatchRequired to true for example
combobox1.MatchEntry=1
combobox1.MatchRequired=True
[]'s