Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from bulletproofnetworks/set_company_name
Set company name
- Loading branch information
Showing
6 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'aws_account_utils/base' | ||
require 'aws_account_utils/login' | ||
|
||
module AwsAccountUtils | ||
class CompanyName < Base | ||
attr_reader :logger, :browser | ||
|
||
def initialize(logger, browser) | ||
@logger = logger | ||
@browser = browser | ||
end | ||
|
||
def set(account_email, account_password, company_name) | ||
logger.debug "Updating Company Name details." | ||
Login.new(logger, browser).execute url, | ||
account_email, | ||
account_password | ||
browser.a(:xpath => '//a[@ng-click="toggleEditingContactInfoState()"]').when_present.click | ||
browser.input(:xpath => '//input[@ng-model="address.company"]').to_subtype.set(company_name) | ||
# screenshot(browser, "1") | ||
browser.button(:xpath => '//button[@ng-click="updateContactInformation()"]').when_present.click | ||
browser.div(:xpath => '//div[@ng-show="options.status == \'success\'"]').wait_until_present | ||
true | ||
rescue Watir::Wait::TimeoutError, Net::ReadTimeout => e | ||
screenshot(browser, "error") | ||
raise StandardError, "#{self.class.name} - #{e}" | ||
end | ||
|
||
private | ||
def url | ||
'https://console.aws.amazon.com/billing/home?#/account' | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module AwsAccountUtils | ||
VERSION = "0.1.3" | ||
VERSION = "0.1.4" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require 'spec_helper' | ||
|
||
describe AwsAccountUtils::CompanyName do | ||
let(:logger) { Logger.new(STDOUT) } | ||
let(:subject) { AwsAccountUtils::CompanyName.new logger, browser } | ||
let(:login) { AwsAccountUtils::Login.new logger, browser } | ||
let(:browser) { double 'browser' } | ||
let(:a) { double 'browser element a' } | ||
let(:div) { double 'browser element div' } | ||
let(:input) { double 'browser input' } | ||
let(:button) { double 'browser button' } | ||
let(:text_field) { double 'browser text field' } | ||
let(:url) { 'https://console.aws.amazon.com/billing/home?#/account' } | ||
let(:name) { 'company_name' } | ||
|
||
it "should update Contact Details" do | ||
expect(logger).to receive(:debug).with('Updating Company Name details.') | ||
expect(browser).to receive(:text_field).with({:id=>"ap_email"}).and_return text_field | ||
expect(text_field).to receive(:when_present).and_return text_field | ||
expect(text_field).to receive(:set) | ||
|
||
expect(browser).to receive(:text_field).with({:id=>"ap_password"}).and_return text_field | ||
expect(text_field).to receive(:when_present).and_return text_field | ||
expect(text_field).to receive(:set) | ||
|
||
expect(browser).to receive(:button).with({:id=>"signInSubmit-input"}).and_return button | ||
expect(button).to receive(:when_present).and_return button | ||
expect(button).to receive(:click) | ||
|
||
expect(browser).to receive(:goto).with(url) | ||
expect(browser).to receive(:url).and_return('https://www.amazon.com/ap/signin?') | ||
expect(logger).to receive(:debug).with('Logging into AWS.') | ||
|
||
expect(browser).to receive(:a) | ||
.with({:xpath=>"//a[@ng-click=\"toggleEditingContactInfoState()\"]"}) | ||
.and_return a | ||
expect(a).to receive(:when_present).and_return a | ||
expect(a).to receive(:click) | ||
|
||
|
||
expect(browser).to receive(:input) | ||
.with({:xpath=>"//input[@ng-model=\"address.company\"]"}) | ||
.and_return input | ||
expect(input).to receive(:to_subtype).and_return input | ||
expect(input).to receive(:set).with('company_name').and_return input | ||
|
||
|
||
expect(browser).to receive(:button) | ||
.with({:xpath=>"//button[@ng-click=\"updateContactInformation()\"]"}) | ||
.and_return button | ||
expect(button).to receive(:when_present).and_return button | ||
expect(button).to receive(:click) | ||
|
||
expect(browser).to receive(:div) | ||
.with({:xpath=>"//div[@ng-show=\"options.status == 'success'\"]"}) | ||
.and_return div | ||
expect(div).to receive(:wait_until_present) | ||
|
||
expect(subject.set('my_user', 'my_password', 'company_name')).to be_truthy | ||
end | ||
end |