Skip to content

Commit

Permalink
resolved PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RAHUL NAIR authored and RAHUL NAIR committed Jan 17, 2022
1 parent bd6454f commit c88f24b
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 132 deletions.
55 changes: 7 additions & 48 deletions packages/yoroi-extension/features/step_definitions/common-steps.js
@@ -1,6 +1,6 @@
// @flow

import { Before, BeforeAll, Given, Then, After, AfterAll, setDefinitionFunctionWrapper, setDefaultTimeout, Status,setWorldConstructor} from 'cucumber';
import { Before, BeforeAll, Given, Then, After, AfterAll, setDefinitionFunctionWrapper, setDefaultTimeout } from 'cucumber';
import * as CardanoServer from '../mock-chain/mockCardanoServer';
import * as ErgoServer from '../mock-chain/mockErgoServer';
import { By } from 'selenium-webdriver';
Expand Down Expand Up @@ -105,30 +105,13 @@ After({ tags: '@invalidWitnessTest' }, () => {
CardanoServer.getMockServer({});
});

const dir1 = './testScreenshots/';

After( async function (scenario) {

console.log("Status :"+scenario.result.status);

const dirFailScr = './testScreenshots/';
if(scenario.result.status == 'failed'){

takeScreenshot(this.driver, 'failedStep');
if(scenario.result.status === 'failed'){
await takeScreenshot(this.driver, 'failedStep');
}
await this.driver.quit();

});


async function attachScreenshot(){
var world = this;

driver.takeScreenshot().then(function (buffer) {
return world.attach(buffer, 'image/png');
});
}

const writeFile = promisify(fs.writeFile);

// Steps that contain these patterns will trigger screenshots:
Expand Down Expand Up @@ -161,25 +144,14 @@ setDefinitionFunctionWrapper((fn, _, pattern) => {

async function takeScreenshot(driver, name) {
// path logic
const dir = `${screenshotsDir}/${testProgress.scenarioName}`;
const dir = `${screenshotsDir}/${testProgress.scenarioName}`;
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
const path = `${dir}/${testProgress.step}_${testProgress.lineNum}-${name}.png`;

const screenshot = await driver.takeScreenshot();
const screenshot = await driver.takeScreenshot();
await writeFile(path, screenshot, 'base64');

}


async function handleAlerts(driver, decider){
let alert = await driver.switchTo().alert();
let alertText = await alert.getText();
if(decider == "accept")
await alert.accept();
else
await alert.dismiss();
}

async function inputMnemonicForWallet(
Expand Down Expand Up @@ -277,26 +249,14 @@ Given(/^I have completed the basic setup$/, async function () {
// language select page
await this.waitForElement('.LanguageSelectionForm_component');
await this.click('//button[text()="Continue"]', By.xpath);
// await this.click('.LanguageSelectionForm_submitButton');

// ToS page
await this.waitForElement('.TermsOfUseForm_component');
//await sleepTh(2000);

const TOS_class_element = await this.driver.findElement(By.css('.TermsOfUseForm_component'));

const checkbox = await TOS_class_element.findElement(By.xpath('//input[@type="checkbox"]'));

const tosClassElement = await this.driver.findElement(By.css('.TermsOfUseForm_component'));
const checkbox = await tosClassElement.findElement(By.xpath('//input[@type="checkbox"]'));
await checkbox.click();


// this.click('//input[@type="checkbox"]', By.xpath);
//await this.click('.SimpleCheckbox_check');
await this.click('//button[text()="Continue"]', By.xpath);
//await this.click('.TermsOfUseForm_submitButton');
// uri prompt page
await acceptUriPrompt(this);

await this.waitForElement('.WalletAdd_component');
});

Expand Down Expand Up @@ -331,7 +291,6 @@ async function acceptUriPrompt(world: any) {
if (world.getBrowser() !== 'firefox') {
await world.waitForElement('.UriPromptForm_component');
await world.click('.allowButton');
//await handleAlerts(world.driver,"accept");
await world.waitForElement('.UriAccept_component');
await world.click('.finishButton');
}
Expand Down
@@ -1,7 +1,7 @@
// @flow

import { When, Then } from 'cucumber';
import { By, WebElement } from 'selenium-webdriver';
import { By } from 'selenium-webdriver';
import i18n from '../support/helpers/i18n-helpers';
import { expect, assert } from 'chai';

Expand Down Expand Up @@ -58,7 +58,6 @@ When(/^I accept the creation terms$/, async function () {
const privacyDlg = await this.driver.findElement(By.xpath('//div[contains(@class,"WalletBackupPrivacyWarningDialog_component")]')) ;
const privacyChkbox = privacyDlg.findElement(By.xpath('//input[@type="checkbox"]'));
privacyChkbox.click();
// await this.click('.SimpleCheckbox_check');
await this.click('//button[text()="Continue"]', By.xpath);
});

Expand All @@ -78,16 +77,11 @@ When(/^I copy and enter the displayed mnemonic phrase$/, async function () {
await this.click(
"(//button[contains(@class,'MnemonicWord_component') " + // any word
` and (text() = '${word}')])`, By.xpath // correct word
// ` and @label = '${word}'])[1]`, By.xpath // correct word
);
}
//const checkboxes = await this.driver.findElements(By.css('.SimpleCheckbox_check'));
const checkboxes = await this.driver.findElements(By.xpath("//input[contains(@class,'PrivateSwitchBase-input')]"));

checkboxes.forEach((box) => box.click());
//await this.click('.WalletRecoveryPhraseEntryDialog .primary');
await this.click('//button[text()="Confirm"]', By.xpath);
console.log("Clicked on Confirm ");
});

When(/^I enter random mnemonic phrase$/, async function () {
Expand Down

0 comments on commit c88f24b

Please sign in to comment.