igniteram / protractor-cli

:dart: An Interactive command line interface & config helper for Protractor.js !
http://npm.im/protractor-cli
MIT License
14 stars 4 forks source link

Auto-generate page objects with cliptor #8

Open igniteram opened 6 years ago

igniteram commented 6 years ago

As per the suggestion given by @cnishina , make cliptor generate common elements of the web page under test like - links, buttons, texts etc.

igniteram commented 6 years ago

I found google chrome's puppeteer which would help achieve this, would start exploring it.

cnishina commented 6 years ago

OMG! Nice find! Going to try it out this weekend.

cnishina commented 6 years ago

Cool. We can get the content of the page with:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({headless: false});
  const page = await browser.newPage();

  await page.goto('http://www.example.com', {waitUntil: 'networkidle2'});
  let content = await page.content();
  console.log(content);

  // await browser.close();
})();

We could get the input, button, and a html from the content.

igniteram commented 6 years ago

Yup, I did see the search.js example of puppeteer. We can get the page objects with this approach but the tricky part is most of the user applications will have a login page. So I was wondering how to handle that with cliptor? Any suggestions?

igniteram commented 6 years ago

ok I got one approach, Add a new command cliptor generate which would ask for the specific page and whether login credentials are required, if yes then interactively cliptor will fetch the login credentials and then pass it to puppeteer to do its magic!