Skip to content

Instantly share code, notes, and snippets.

@coreycollins
Created October 12, 2011 15:15
Show Gist options
  • Select an option

  • Save coreycollins/1281472 to your computer and use it in GitHub Desktop.

Select an option

Save coreycollins/1281472 to your computer and use it in GitHub Desktop.

Revisions

  1. coreycollins created this gist Oct 12, 2011.
    47 changes: 47 additions & 0 deletions autoprovision.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    require 'csv'
    require 'watir-webdriver'
    require 'fileutils'
    require 'net/http'

    ####### USAGE #######
    #
    # ruby autoprovison.rb ids.txt
    #
    #####################


    IOS_PROVISIONING_DISTRIBUTION_URL = "https://developer.apple.com/ios/manage/provisioningprofiles/viewDistributionProfiles.action"

    puts "Navigating to apple portal"

    b = Watir::Browser.start(IOS_PROVISIONING_DISTRIBUTION_URL)

    unless b.title =~ /.*App IDs - iOS Provisioning Portal - Apple Developer.*/
    puts "Logging in.."
    b.text_field(:name, "theAccountName").set "#####USERNAME#####"
    b.text_field(:name, "theAccountPW").set "#####PASSWORD#####"
    b.send_keys :enter
    end


    CSV.foreach(ARGV[0]) do |row|
    begin
    id = row[0]
    sleep(7)

    puts " Adding new distribution profile...#{id}"
    b.link(:id, "index_").click

    puts " Filling in profile name."
    b.text_field(:name, "provisioningProfileName").set id

    puts " Selecting app id."
    b.select_list(:name, "cfBundleDisplayId").select_value id

    puts " Saving."
    b.button(:id, "save_submit").click

    rescue Exception => exp
    puts exp.message
    end
    end