Class: Superbot::Cloud::CLI::Webdriver::CreateCommand

Inherits:
BaseCommand show all
Defined in:
lib/superbot/cloud/cli/webdriver/create_command.rb

Instance Method Summary collapse

Methods inherited from LoginRequiredCommand

#run, run

Methods included from Validations

#require_login

Instance Method Details

#create_webdriverObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/superbot/cloud/cli/webdriver/create_command.rb', line 15

def create_webdriver
  request_body = {
    organization_name: organization,
    desiredCapabilities: {
      browserName: 'chrome',
      superOptions: {}
    }
  }
  request_body[:desiredCapabilities][:superOptions][:region] = region if region
  puts "Creating a webdriver session..."
  puts "Please wait for Session ID or press [ctrl/cmd + c] to exit"
  session = Excon.post(
    [Superbot.webdriver_endpoint(local? ? 'local_cloud' : 'cloud'), 'wd/hub/session'].join('/'),
    persistent: true,
    headers: { 'Authorization' => Superbot::Cloud.authorization_header, 'Content-Type' => 'application/json' },
    body: request_body.to_json,
    connect_timeout: 3,
    read_timeout: 500,
    write_timeout: 500
  )
  parsed_response = JSON.parse(session.body)
  puts parsed_response['error'] || parsed_response['sessionId']
end

#executeObject



11
12
13
# File 'lib/superbot/cloud/cli/webdriver/create_command.rb', line 11

def execute
  create_webdriver
end