I'm trying to validate the existence of a UIButton that is initially disabled continueButton.isEnabled = false.
When I check the tree in calabash-ios console I get the following result
[UIWindow]
[UIView]
[UIView]
[MyProject.GradientView]
[UIImageView] [id:logo-1] [label:Logo 1]
[UIImageView] [id:logo-2] [label:Logo 2]
[MyProject.UnderlinedTextField] [label:Email] [text:]
[UITextFieldLabel] [label:EMAIL] [text:EMAIL]
[UIAccessibilityTextFieldElement] [label:Email] [text:EMAIL]
[UIButton] [label:Let's go]
[UIButtonLabel] [label:LET'S GO] [text:LET'S GO]
true
However, when I try to use query("button") I get an empty array. If the button is enabled and use query again the result is:
[
[0] {
"id" => nil,
"description" => "<UIButton: 0x7fcdc8f1b6b0; frame = (23 571; 329 63); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x608000228b20>>",
"label" => "Let's go",
"frame" => {
"y" => 571,
"x" => 23,
"width" => 329,
"height" => 63
},
"accessibilityElement" => true,
"value" => nil,
"alpha" => 1,
"enabled" => true,
"visible" => 1,
"selected" => false,
"class" => "UIButton",
"rect" => {
"y" => 571,
"center_x" => 187.5,
"center_y" => 602.5,
"x" => 23,
"width" => 329,
"height" => 63
}
}
]
Why a disabled button is not listed when using query? Is there any way to validate if a button exists regardless of its enable state?
UPDATE
When using query ("all button") as suggested by jmoody I'm able to get the button listed.
[
[0] {
"id" => nil,
"description" => "<UIButton: 0x7fe05ad18000; frame = (23 571; 329 63); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x60000022d940>>",
"label" => "Lets go",
"frame" => {
"y" => 571,
"x" => 23,
"width" => 329,
"height" => 63
},
"accessibilityElement" => true,
"value" => nil,
"alpha" => 1,
"enabled" => false,
"visible" => 0,
"selected" => false,
"class" => "UIButton",
"rect" => {
"y" => 571,
"center_x" => 187.5,
"center_y" => 602.5,
"x" => 23,
"width" => 329,
"height" => 63
}
}
]
When the button is disabled, is it physically visible?
# All buttons regardless of visibility.
query("all button")
# Ask every button if is enabled.
query("all button", :isEnabled)
# Filter buttons by disabled
query("all button isEnabled:0")
Why a disabled button is not listed when using query?
Calabash uses a visibility heuristic to determine if a view is visible.
At first glance, it does not look like Calabash asks anything about whether a UIControl is enabled or disabled to determine if a view is visible.
I have the same issue, but I can suggest a workaround:
specify different accessibilityIdentifier for the button when it's hidden or visible, something like my_super_button_hidden, when it's hidden and my_super_button_visible otherwise
always use all keyword in your button query
examine visibility by checking accessibilityIdentifier
examine enabled state as you did before
checked on ruby 2.4.0, run_loop 2.3.1
Related
As a source file I have a square image (500x500).
As soon as I use the cropArea, the preview shows that the entire area has been selected (500x500px)
'cropVariants' => [
'default' => [
'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.crop_variant.default',
'allowedAspectRatios' => [
'1:1' => [
'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.1_1',
'value' => 1.0
]
],
'selectedRatio' => '1:1',
'cropArea' => [
'x' => 0.0,
'y' => 0.0,
'width' => 1.0,
'height' => 1.0,
],
],
],
But in the database, however, the following data (sys_file_reference) is stored: (problem y-coordinate)
{"default":{"cropArea":{"height":1,"width":1,"x":0,"y":-0.002},"selectedRatio":"1:1","focusArea":null}}
In Fluid this is my code:
<f:image src="{item.image.0.reference.uid}" alt="{item.image.0.reference.description}" treatIdAsReference="1" />
As a result that image is rendered in fluid with 500 x 499 pixels. (1px is missing)
Any idea how I can adjust the behavior? so that the y-coordinate is also set to 0 and the whole selection is rendered?
Is it possible to disable the options in a select element?
I have a form with a select element that by default has a lot of options available. During form creation, depending on information retrieved from the database, i would like to disable certain options.
Some research came up with
$form->get('selectElement')->setAttribute("disabled", array(0, 1, 2));
...which should disable the first 3 options, but unfortunately does not.
You must use the setAttribute() method to set the attributes of your select element, not its options. For this, you should use setValueOptions():
$myOptions = $form->get('selectElement')->getValueOptions();
foreach ([0, 1, 2] as $value) {
$myOptions [$value]['disabled'] = true ;
}
$form->get('selectElement')->setValueOptions($myOptions);
$myOptionsmust be an array of options:
[
[
'label' => 'My first option',
'disabled' => false,
'value' => 1
],
[
'label' => '2nd option',
'disabled' => false,
'value' => 2
],
[
'label' => '3rd option disabled',
'disabled' => true,
'value' => 3
],
]
I have a label on iOS app that I'm not able to touch
irb(main):022:0> label "label"
[
[0] "Create account",
[1] "Log in",
[2] "com.blabla - v505"
]
I want to click the last element that basically is this
irb(main):014:0> query("view {accessibilityLabel LIKE 'com.blabla*'}")
[
[0] {
"class" => "UILabel",
"id" => nil,
"rect" => {
"center_x" => 160,
"y" => 519,
"width" => 280,
"x" => 20,
"center_y" => 540.5,
"height" => 43
},
"frame" => {
"y" => 519,
"width" => 280,
"x" => 20,
"height" => 43
},
"label" => "com.blabla - v505",
"description" => "<UILabel: 0x7a1ebac0; frame = (20 519; 280 43); text = 'com.blabla.enterprise.cal....'; clipsToBounds = YES; opaque = NO; autoresize = W+TM; gestureRecognizers = <NSArray: 0x7a1e8900>; layer = <_UILabelLayer: 0x7a1ebbe0>>"
}
]
I tried different ways to click that element but all give me the same error
NoMethodError: undefined method `to_sym' for nil:NilClass
I tried the following
. touch("view {accessibilityLabel LIKE 'com.blabla*'}")
. tap_mark label("label")[2]
any idea or suggestion for me to be able to touch that label?
Have you tried tap_mark label ("com.blabla -v505")? Maybe I'm misunderstanding.
I can set height for row. But it is fixed height. if content increases height does not increase automatically. just clip extra content.
Here is my code. how can i set default height 20 not fixed height
pdf.table([applicant_data],
:cell_style => {
:inline_format => true,
:padding => [3, 3,3,3], :size => 9,
:border_widths => [0.5, 0.5, 0.5, 0.5],
:height => 20,
#:font_style => :bold
},
:column_widths => {0 => 30, 1 => 110, 2 => 50, 3 => 110, 4 => col_wid_bo })
In the table block, you can set the row height:
pdf.table data do
rows(0..-1).each do |r|
r.height = 25 if r.height < 25
end
end
I solved the problem by setting height dynamically based on string length. If string fits in one line the default height , if not not increase height based on string length. That's it.
I am using Google maps for rails and I have everything setup properly but I can't seem to figure out how to set the default zoom number. I tried setting it in gmaps4rails.base.js.coffee here:
#default_map_options =
id: 'map'
draggable: true
detect_location: false # should the browser attempt to use geolocation detection features of HTML5?
center_on_user: false # centers map on the location detected through the browser
center_latitude: 0
center_longitude: 0
zoom: 7
maxZoom: null
minZoom: null
auto_adjust : true # adjust the map to the markers if set to true
auto_zoom: true # zoom given by auto-adjust
bounds: [] # adjust map to these limits. Should be [{"lat": , "lng": }]
raw: {} # raw json to pass additional options
but i dont think that worked properly. Is there a way to add the zoom number when creating the map:
<%= gmaps(:markers => {:data => #json,
:options => {:raw => '{ animation: google.maps.Animation }' } },
:map_options => { :raw => '{ disableDefaultUI: false,
scrollwheel: true }' }) %>
nothing I do seems to do anything, it is always zoomed all the way in. thanks!
Here is my solution, which works (note that i use haml. Use <%= %> for erb):
= gmaps("map_options" => { "detect_location" => true, "center_on_user" => true, "auto_zoom" => false, "zoom" => 16},"markers" => { "data" => #json })
You need to set :auto_zoom => false, :zoom => value
<%= gmaps(:markers => {:data => #json,
:options => {:raw => '{ animation: google.maps.Animation }' } },
:map_options => { :raw => '{ disableDefaultUI: false,
scrollwheel: true,
auto_zoom => false,
zoom => 10 }' }) %>
Not sure exactly what you are trying to accomplish but my challenge was that with auto zoom it would zoom in so far that the perspective was all wrong. My solution was to change the max zoom value in the base coffee script. Snippet below. Note the auto remains true.
center_longitude: 0
zoom: 7
maxZoom: 18
minZoom: null
auto_adjust : true # adjust the map to the markers if set to true
auto_zoom: true # zoom given by auto-adjust
bounds: [] # adjust map to these limits. Should be [{"lat": , "lng": }]
raw: {} # raw json to pass additional options
The other haml solution mention in the answers also works for a single page.