I want to click a link that contains certain text. I have tried using an X-Path expression and that is not working. The application I am testing is Multi Page Application so I am not sure if the new page is generated.
The HTML:
<a class="text-major ev-pick-this-event" href="/cgi-bin/ncommerce3/SEGetEventInfo?ticketCode=GS%3AAMTX%3AHUSKERS%3ASLP2%3A&linkID=BQFN80-AMTX&shopperContext=&pc=&caller=&appCode=&groupCode=SLP&cgc=&dataAccId=129&locale=en_US&siteId=ev_BQFN80-AMTX">HUSKERS - SLP2 - Ranges</a>
What I have tried:
DislplayEventList.js
class DisplayEventListPage {
async clickEventListLink(page) {
const slp2ItemLink = await page.$(
'//a[contains(., "HUSKERS - SLP2 - Ranges")]'
);
await slp2ItemLink.click();
}
}
module.exports = DisplayEventListPage;
navigate.test.js
const path = require("path");
const config = require("config");
const url = config.get("url");
const DisplayGroupListPage = require("../pageObjects/DisplayGroupList");
const DisplayEventListPage = require("../pageObjects/DisplayEventList");
let groupListPage = new DisplayGroupListPage();
let eventListPage = new DisplayEventListPage();
describe("Test Navigation", () => {
beforeAll(async () => {
await page.goto(url);
await page.screenshot({ path: "groupListPage.png" });
await groupListPage.clickGroupName(page);
await page.screenshot({ path: "eventListPage.png" });
await page.waitFor(3000);
const pageURL = await page.url();
console.log(pageURL);
await eventListPage.clickEventListLink(page);
});
it('should be titled "evenue 1.5 | Online Ticket Office | HUSKERS - SLP2 - Ranges', async () => {
await expect(page.title()).resolves.toMatch(
"evenue 1.5 | Online Ticket Office | HUSKERS - SLP2 - Ranges"
);
});
});
Error I receive:
Evaluation failed: DOMException: Failed to execute 'querySelector' on 'Document': '//a[contains(., "HUSKERS - SLP2 - Ranges")]' is not a valid selector.
Aucun commentaire:
Enregistrer un commentaire