import { browser, $, $$, by, element, protractor } from "protractor";
//import { SearchPageObject } from "../pages/searchPage";
const { When, Then } = require("cucumber");
const { Given } = require("cucumber");
var chai = require('chai');
var retry = require('retry');
var chaiAsPromised = require('chai-as-promised');
var count2 = 1;
chai.use(chaiAsPromised);
var expect = chai.expect;
When(/^I type "(.*?)"$/, async (text) => {
await browser.waitForAngularEnabled(false);
await browser.driver.get('https://www.baidu.com');
await $('#kw').sendKeys('protractor');
await $('#su').click();
});
Then(/^I click on search button$/, { timeout: 60 * 1000 }, async () => {
//browser.actions().sendKeys(protractor.Key.ENTER).perform();
console.info("\n\r");
var EC = protractor.ExpectedConditions;
await browser.wait(EC.presenceOf($('.result.c-container h3')), 500000);
var s = $$('.result.c-container h3');
await s.each(async p => { console.log( (count2++)+ "->" + await p.getText())});
async function getOneItem(f) {
return console.log( (count2++)+ "->" + await f.getText());
}
});
Given(/^I am on google page$/, () => {
//browser.driver.get('https://wwww.baidu.com');
});
});
});
}