I am using this example but I am not able to automate the "New Tab" button.
Here is a screenshot of the HTML document:
I am trying to solve this by using the first answer from this topic.
/// <reference types="cypress" />
describe('Example shows how to work with browser windows.', () => {
it('Example shows how to work within button that opens new tab without "target: _blank" and "href" attributes.', () => {
cy.visit('https://demoqa.com/browser-windows')
cy.window().then(win => {
cy.stub(win, 'open').as('open')
})
cy.xpath('//*[@id="tabButton"]').click()
cy.get('@open').should('have.been.calledOnceWithExactly', '/sample')
})
})
I am not sure what I miss.