Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async addCard(card: Card): Promise
{
// A driver alias so the code isn't *as* unwieldy
const driver: ThenableWebDriver = this.browser.driver;
await driver.findElement(By.css(".a-size-base"))
.click();
if (card.cardholderName !== undefined && card.expirationMonth !== undefined && card.expirationYear !== undefined)
{
await driver.findElement(By.name("ppw-accountHolderName"))
.sendKeys(card.cardholderName);
await driver.findElement(By.name("addCreditCardNumber"))
.sendKeys(card.cardNumber);
await driver.findElement(By.xpath(`//select[@name='ppw-expirationDate_month']/option[${card.expirationMonth}]`))
.click();
await driver.findElement(By.xpath(`//select[@name='ppw-expirationDate_year']/option[.=${card.expirationYear}]`))
.click();
await driver.findElement(By.name("ppw-widgetEvent:AddCreditCardEvent"))
.click();
await driver.wait(until.elementLocated(By.name("ppw-widgetEvent:SelectAddressEvent")))
.click();
} else
{
throw new Error(`${card.friendlyReference}: ${card.cardholderName}/${card.expirationMonth}/${card.expirationYear}`);
}
function fillMetadataFields(driver) {
driver.findElement(By.css('#api-metadata button')).click();
driver.findElement(By.name('organization.name')).sendKeys('Name');
driver.findElement(By.name('organization.description')).sendKeys('Description');
driver.findElement(By.name('contact.name')).sendKeys('Name');
driver.findElement(By.name('contact.phone')).sendKeys('+11111111111');
driver.findElement(By.name('contact.email')).sendKeys('aa@bb.ccc');
driver.findElement(By.name('service.name')).sendKeys('Name');
driver.findElement(By.name('service.description')).sendKeys('Description');
driver.findElement(By.name('service.validSince')).sendKeys('01/01/2000');
driver.findElement(By.name('service.validUntil')).sendKeys('01/01/2030');
driver.findElement(By.name('service.serviceLevelAgreement')).sendKeys('Agreement');
}
function fillMetadataFields(driver) {
driver.findElement(By.css('#api-metadata button')).click();
driver.findElement(By.name('organization.name')).sendKeys('Name');
driver.findElement(By.name('organization.description')).sendKeys('Description');
driver.findElement(By.name('contact.name')).sendKeys('Name');
driver.findElement(By.name('contact.phone')).sendKeys('+11111111111');
driver.findElement(By.name('contact.email')).sendKeys('aa@bb.ccc');
driver.findElement(By.name('service.name')).sendKeys('Name');
driver.findElement(By.name('service.description')).sendKeys('Description');
driver.findElement(By.name('service.validSince')).sendKeys('01/01/2000');
driver.findElement(By.name('service.validUntil')).sendKeys('01/01/2030');
driver.findElement(By.name('service.serviceLevelAgreement')).sendKeys('Agreement');
}
function fillMetadataFields(driver) {
driver.findElement(By.css('#api-metadata button')).click();
driver.findElement(By.name('organization.name')).sendKeys('Name');
driver.findElement(By.name('organization.description')).sendKeys('Description');
driver.findElement(By.name('contact.name')).sendKeys('Name');
driver.findElement(By.name('contact.phone')).sendKeys('+11111111111');
driver.findElement(By.name('contact.email')).sendKeys('aa@bb.ccc');
driver.findElement(By.name('service.name')).sendKeys('Name');
driver.findElement(By.name('service.description')).sendKeys('Description');
driver.findElement(By.name('service.validSince')).sendKeys('01/01/2000');
driver.findElement(By.name('service.validUntil')).sendKeys('01/01/2030');
driver.findElement(By.name('service.serviceLevelAgreement')).sendKeys('Agreement');
}
function fillMetadataFields(driver) {
driver.findElement(By.css('#api-metadata button')).click();
driver.findElement(By.name('organization.name')).sendKeys('Name');
driver.findElement(By.name('organization.description')).sendKeys('Description');
driver.findElement(By.name('contact.name')).sendKeys('Name');
driver.findElement(By.name('contact.phone')).sendKeys('+11111111111');
driver.findElement(By.name('contact.email')).sendKeys('aa@bb.ccc');
driver.findElement(By.name('service.name')).sendKeys('Name');
driver.findElement(By.name('service.description')).sendKeys('Description');
driver.findElement(By.name('service.validSince')).sendKeys('01/01/2000');
driver.findElement(By.name('service.validUntil')).sendKeys('01/01/2030');
driver.findElement(By.name('service.serviceLevelAgreement')).sendKeys('Agreement');
}
function addDocumentationLink(driver) {
driver.findElement(By.name('documentation_link'))
.sendKeys('https://www.google.co.in')
.then(function(){
driver.sleep(1000);
});
}
await driver.wait(until.titleIs("Amazon Sign In"));
try
{
await driver.findElement(By.id("ap_email"))
.sendKeys(this.username);
} catch
{
assert(await driver.findElement(By.css(".a-size-base"))
.getText() === this.username);
}
await driver.findElement(By.id("ap_password"))
.sendKeys(this.password);
const rememberMeElement: WebElement = await driver.findElement(By.name("rememberMe"));
if (!await rememberMeElement.isSelected())
{
await rememberMeElement.click();
}
await driver.findElement(By.id("signInSubmit"))
.click();
}
const driver: ThenableWebDriver = this.browser.driver;
await driver.findElement(By.css(".a-size-base"))
.click();
if (card.cardholderName !== undefined && card.expirationMonth !== undefined && card.expirationYear !== undefined)
{
await driver.findElement(By.name("ppw-accountHolderName"))
.sendKeys(card.cardholderName);
await driver.findElement(By.name("addCreditCardNumber"))
.sendKeys(card.cardNumber);
await driver.findElement(By.xpath(`//select[@name='ppw-expirationDate_month']/option[${card.expirationMonth}]`))
.click();
await driver.findElement(By.xpath(`//select[@name='ppw-expirationDate_year']/option[.=${card.expirationYear}]`))
.click();
await driver.findElement(By.name("ppw-widgetEvent:AddCreditCardEvent"))
.click();
await driver.wait(until.elementLocated(By.name("ppw-widgetEvent:SelectAddressEvent")))
.click();
} else
{
throw new Error(`${card.friendlyReference}: ${card.cardholderName}/${card.expirationMonth}/${card.expirationYear}`);
}
}
export function name(name: string): By {
return By.name(name);
}