0

I am testing a website i.e console.internetcomputerservices.com, please refer the below code:

/// <reference types="cypress" />


describe("Basic tests", () => {
   before(() => {
      cy.visit("https://console.internetcomputerservices.com", {
        onBeforeLoad(win) {
        win.localStorage.setItem(
        "token",
        "my-token"
      );
    },
  });
});
it.only("should be able to run test 1", async () => {
    cy.viewport(1280, 720)
 //Clicks on Creat DApp
  cy.contains('Create DApp').click()
 //Clicks on Static website 
  cy.contains('Static Website').click()
 //clicks on "Connect with github"
  cy.contains('Connect with github').click()
 //The origin is changed to github.com inside which following operation takes place
  cy.origin('https://github.com', ()=>{
    cy.get('input[name="login"]').type('my-email')
    cy.get('input[name="password"]').type('my-password')
    cy.get('[type="submit"]').click()
    cy.get('[href="/settings/installations/29576211"]').click()
    cy.contains('Only select repositories').click()
    cy.contains('All repositories').click()
    cy.get('.js-integrations-install-form-submit.btn-primary.btn.float-left.mr-2').click()
  })
 //Comes out of github.com back to console.internetcomputerservices.com
 //(Expected) cypress will identify the placeholder and type "intro-2"
 // but this doesn't happen, cypress doesn't identify any element inside the DOM
  cy.get('input[placeholder="Search…"]').type('intro-2')

});
});

When we return back to our home website, i expect that the cypress identifies the placeholder and type in "intro-2", to check that was it particular to placeholder, i realised that cypress is not able to identify any element on DOM.

This is the image and if you see i want to access the first search bar to type "intro-2" If you refer the Search bar, i want to access one with placeholder='Search...'

enter image description here

enter image description here

I apologies for poor choice of words, i am beginner in this and not familiar with jargon, I hope you understand my question.

yash
  • 77
  • 3
  • 10
  • Have you tried `cy.get('[aria-label=search]')` instead? – jjhelguero Oct 06 '22 at 17:11
  • @jjhelguero, no, the reason that i didn't do it is, as we know that there are two search bar and inspecting them i realised that both have [aria-label=search] – yash Oct 07 '22 at 09:47
  • If only one is visible on the page at this time you can use jquery selector :visible. `cy.get('[aria-label=search]:visible')` – jjhelguero Oct 07 '22 at 14:36

0 Answers0