Skip to content

Commit f2122de

Browse files
Don't crash when mainWindow is UIAElementNil
1 parent ef9cc99 commit f2122de

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/appium_lib/ios/helper.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,13 @@ def _by_json opts
531531
# will be present.
532532
_validate_object opts[:name], opts[:label], opts[:value]
533533

534+
# note that mainWindow is sometimes nil so it's passed as a param
535+
# $._elementOrElementsByType will validate that the window isn't nil
534536
element_or_elements_by_type = <<-JS
535537
(function() {
536-
var opts = #{opts.to_json}
538+
var opts = #{opts.to_json};
537539
538-
return $.mainWindow()._elementOrElementsByType(opts);
540+
return $._elementOrElementsByType($.mainWindow(), opts);
539541
})();
540542
JS
541543

0 commit comments

Comments
 (0)