Skip to content

memlab not navigating pages #39

Closed
Closed

Description

@QAInsights

When I run the below scenario, the script is not navigating to any page clicks. It is just taking snapshots from the home page.

function url() {
  console.log("Returning URL");
  return 'https://store.qainsights.com/';
}

async function accessories(page) {
  console.log("Click on Accessories link");
  await page.click('//a[href="/accessories"]');
}

async function apparel(page) {
  console.log("Click on Apparel link");
  await page.click('//a[href="/apparel"]');
}

async function back(page) {
  console.log("Go to Home page");
  await page.click('//a[href="/"]');
}

module.exports = {accessories, apparel, back, url};

memlab version

memlab@1.1.28
 @memlab/heap-analysis@1.0.9
 @memlab/e2e@1.0.12
 @memlab/core@1.1.11
 @memlab/cli@1.0.14
 @memlab/api@1.0.11

Activity

  1. JacksonGL commented on Oct 1, 2022

    @JacksonGL
    Member

    @QAInsights Please use the API mentioned in the documentation.

    MemLab doesn't provide callback accessories or apparel. Use action instead:

    function url() {
      console.log("Returning URL");
      return 'https://store.qainsights.com/';
    }
    
    async function action(page) {
      console.log("Click on Accessories link");
      await page.click('//a[href="/accessories"]');
    }
    
    async function back(page) {
      console.log("Go to Home page");
      await page.click('//a[href="/"]');
    }
    
    module.exports = {action, back, url};
    function url() {
      console.log("Returning URL");
      return 'https://store.qainsights.com/';
    }
    
    async function action(page) {
      console.log("Click on Apparel link");
      await page.click('//a[href="/apparel"]');
    }
    
    async function back(page) {
      console.log("Go to Home page");
      await page.click('//a[href="/"]');
    }
    
    module.exports = {action, back, url};

    PS: console.log is not recommended in test script as it will disrupt the memlab console output.

  2. JacksonGL commented on Oct 1, 2022

    @JacksonGL
    Member

    Also double check the correctness of the css selector. The website under test is having some infinite loop dumping tons of console.error messages in web console

  3. QAInsights commented on Oct 1, 2022

    @QAInsights
    Author

    Thank @JacksonGL I was using Firefox to inspect the elements. In FF Console, I do not see any recursive errors, but in Chrome it is showing up. Below code is working fine, but it is crashing due to recursive logging.

    Let me try with another app.

    const scenario = {
      url: () => 'https://store.qainsights.com/',
      action: async (page) => {
        await page.click('a[href="/apparel"]');
      },
      back: async (page) => {
        await page.click('a[href="/"]');
      },
    }
    
    module.exports = scenario;
    
  4. QAInsights commented on Oct 1, 2022

    @QAInsights
    Author

    @JacksonGL Finally I was able to take a snapshot :)

    const scenario = {
      url: () => 'https://academy.qainsights.com/courses',
      action: async (page) => {
        await page.click('a[href="/about"]');
      },
      back: async (page) => {
        await page.click('a[href="/courses"]');
      },
    }
    
    module.exports = scenario;
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions