Changing iOS Simulator language from terminal

149 views
Skip to first unread message

DV Ravikumar

unread,
Nov 25, 2015, 6:14:17 AM11/25/15
to calabash-ios
Hi,
 

I need a help in lunching the simulator with  specific language from terminal .
for this I tried changind the simulator .GlobalPreferences.plist values for AppleLanguages and AppleLocale(For Ex : AppleLanguages[0] = pt,AppleLocale = pt_BR) but simulator is still launching in english only.

I have one requirement with respect to UILable :
How can i check the label text is truncating or not using Calabash.

Please let me know if you guys having any suggestions.

Thanks In advance

Regards,
DV Ravikumar

iushakov

unread,
Nov 25, 2015, 6:35:43 AM11/25/15
to calabash-ios
Take a look here: https://gist.github.com/tejasv02/f3f47daebc8998ef233c


you can specify a @tag and launch simulator with desired language.

Joshua Moody

unread,
Nov 25, 2015, 7:37:42 AM11/25/15
to calabash-ios
You can also just pass the local as an argument from calabash.

https://github.com/calabash/calabash-ios/issues/880

jjm

DV Ravikumar

unread,
Nov 26, 2015, 12:21:12 AM11/26/15
to calabash-ios
Thanks for your reply it helped me,got the problem with my script, I've modified my script it's working fine.

Many Thanks.

DV Ravikumar

unread,
Nov 26, 2015, 12:22:17 AM11/26/15
to calabash-ios
Thanks for yor reply. It helped me.

DV Ravikumar

unread,
Nov 26, 2015, 12:27:19 AM11/26/15
to calabash-ios
Can you help me out how to check wether the UILabel text is truncating or not using calabash.

Thanks in advance.

Regards,
Ravi


On Wednesday, November 25, 2015 at 6:07:42 PM UTC+5:30, Joshua Moody wrote:

DV Ravikumar

unread,
Nov 26, 2015, 12:27:38 AM11/26/15
to calabash-ios
Can you help me out how to check wether the UILabel text is truncating or not using calabash

Thanks in advance.

Regards,
Ravi

On Wednesday, November 25, 2015 at 5:05:43 PM UTC+5:30, iushakov wrote:

iushakov

unread,
Nov 26, 2015, 2:33:53 AM11/26/15
to calabash-ios
Take a look on my code example from console below. Hope it helps you.



irb(main):017:0> query('UITextFieldLabel')[0]

{

                     "id" => nil,

            "description" => "<UITextFieldLabel: 0x7f9a5a815f90; frame = (70 1.5; 186 34.5); text = 'Ronald Reagan Washington ...'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f9a5a816410>>",

                  "label" => "Ronald Reagan Washington National (DCA)",

                  "frame" => {

            "y" => 1.5,

            "x" => 70,

        "width" => 186,

       "height" => 34.5

   },

   "accessibilityElement" => true,

                  "value" => "Ronald Reagan Washington National (DCA)",

                  "alpha" => 1,

                "enabled" => true,

                "visible" => 1,

                   "text" => "Ronald Reagan Washington National (DCA)",

                  "class" => "UITextFieldLabel",

                   "rect" => {

              "y" => 154,

       "center_x" => 173,

       "center_y" => 171.25,

              "x" => 80,

          "width" => 186,

         "height" => 34.5

   }

}

irb(main):018:0> query('UITextFieldLabel', :description)[0]

"<UITextFieldLabel: 0x7f9a5a815f90; frame = (70 1.5; 186 34.5); text = 'Ronald Reagan Washington ...'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7f9a5a816410>>"

irb(main):019:0> my_city = "Ronald Reagan Washington National (DCA)"

"Ronald Reagan Washington National (DCA)"

irb(main):020:0> query('UITextFieldLabel', :description)[0].include?(my_city)

false

irb(main):021:0> truncated = "Ronald Reagan Washington ..."

"Ronald Reagan Washington ..."

irb(main):022:0> query('UITextFieldLabel', :description)[0].include?(truncated)

true


DV Ravikumar

unread,
Nov 27, 2015, 2:00:19 AM11/27/15
to calabash-ios
Thanks for you reply.

My usecase is:
I'll get string from localization and with particular key and assigned to a UILabel.while doing UIAutomation i'll compare the UILabel text with Localisation key value.

I tried the example you posted in my use case like : query("label marked:<label_id> ", :description)[0].include?(<my localization text>) is returning true always for me even text is truncated in UILabel on the UI or not truncated also.

Please let me know is anything wrong i'm doing or you have any other suggestions.

Regards,
Ravi  

iushakov

unread,
Nov 27, 2015, 7:20:50 AM11/27/15
to calabash-ios
Please, provide your output from console for this TextField, label 

DV Ravikumar

unread,
Nov 29, 2015, 3:54:54 AM11/29/15
to calabash-ios
Hi,

My Code what i have written for checking label text truncation

def truncated(elementQuery,text)
    desc = query(elementQuery, :description)[0]
    puts "Label Description : #{desc}"
    puts "Localization text: #{text}"
    is_trincated = query(elementQuery, :description)[0].include?(text)
    puts "Truncation Check Result :#{is_trincated}"
end

PF Console output below attched screenshot for how label is displaying on the UI.

@Label

  Scenario: Create Philips Account Steps                                                     # features/my_first.feature:18

    Given I am on the Register Screen                                                        # features/step_definitions/my_first_steps.rb:2

    Then I wait to see label 'ExplanatoryLabel' with key Create_Account_Hint_Password_lbltxt # features/step_definitions/check_localization.rb:12

      Langauage :en Create_Account_Hint_Password_lbltxt

      Label Description : <UILabel: 0x7f818b67e5c0; frame = (57.5 17; 260 12); text = 'Protect your privacy by c...'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; tintColor = UIDeviceRGBColorSpace 0 0 0 1; layer = <_UILabelLayer: 0x7f818b67d330>>

      Localization text: Protect your privacy by choosing a strong password.

      Truncation Check Result :false

    Then I wait for 10 seconds                                                               # calabash-cucumber-0.16.4/features/step_definitions/calabash_steps.rb:208



Regards,

Ravi


label_on_the_screen.png

iushakov

unread,
Nov 30, 2015, 2:53:23 AM11/30/15
to calabash-ios
Which text you paste in brackets? If you enter full sentence - then it is correct behaviour of false in results, if you will enter truncated text you will see true. In you console output you see it as well that text is truncated.

Try to update you method.

def truncated(elementQuery,text)
    desc = query(elementQuery, :description)[0]
    is_truncated = query(elementQuery, :description)[0].include?(text)
   
    if is_truncated
      puts "Text is not truncated, #{desc}"
    else
      puts "Text is truncated, #{desc}"
    end
end

DV Ravikumar

unread,
Nov 30, 2015, 4:03:04 AM11/30/15
to calabash-ios
The text in brackets will be always full sentence,the text in UILabel is truncated on the UI(Screen).But when i change the height of the label in the storyboard makes the text on the Label will visible completly,that time also i'm getting same result as false.

OutPut :

 @Label

  Scenario: Create Philips Account Steps                                                     # features/my_first.feature:18

    Given I am on the Register Screen                                                        # features/step_definitions/my_first_steps.rb:2

    Then I wait to see label 'ExplanatoryLabel' with key Create_Account_Hint_Password_lbltxt # features/step_definitions/check_localization.rb:12

      Langauage :en Create_Account_Hint_Password_lbltxt

      Label Description : <UILabel: 0x7f82dbe4cc50; frame = (57.5 17; 260 24); text = 'Protect your privacy by c...'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; tintColor = UIDeviceRGBColorSpace 0 0 0 1; layer = <_UILabelLayer: 0x7f82dbe622e0>>

      Localization text: Protect your privacy by choosing a strong password.

      Text is truncated, <UILabel: 0x7f82dbe4cc50; frame = (57.5 17; 260 24); text = 'Protect your privacy by c...'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; tintColor = UIDeviceRGBColorSpace 0 0 0 1; layer = <_UILabelLayer: 0x7f82dbe622e0>>

    Then I wait for 10 seconds                                                               # calabash-cucumber-0.16.4/features/step_definitions/calabash_steps.rb:208


ExpectedOutPut : Text is not truncated,<Label Description has to print>


Regards,

Ravi

Screen Shot 2015-11-30 at 2.20.47 PM.png

DV Ravikumar

unread,
Nov 30, 2015, 4:17:46 AM11/30/15
to calabash-ios
Hi Joshua,

Can you help me how to check wether the UILabel text is truncated or not on the UI(iPhone screen because of the in sufficient height or width).

Thanks in andvance.

Regards,
Ravi


On Wednesday, November 25, 2015 at 6:07:42 PM UTC+5:30, Joshua Moody wrote:
Reply all
Reply to author
Forward
0 new messages