vendredi 29 janvier 2021

TestCafe: console.log() the value of a selector

I try to select the text value SR-12948 of the span below with a TestCafe selector and then assign it to a const. So I can add it as a string to the withAttribute method. That doesn't really work. So I want to check what the value of my const srCaseIDString is. Is it possible to do that with a console log? So it logs the value of that const in the same terminal as my test results and errors appear?

This is my test:

<span data-template="" data-test-id="2014100715101007275150" class="supporting_text_il" style="">SR-12948</span>

import { Selector, t } from "testcafe";
import XPathSelector from "../utils/xpath-selector";

const button= Selector("#button");  

test("First Test", async (t) => {
     await t
        .click(button);

        const srCaseID = await  XPathSelector("//span[@data-test-id='2014100715101007275150']").innerText;
        const srCaseIDString = await srCaseID.innertext;

        console.log(srCaseIDString )

        const iframeCase = await Selector('iframe').withAttribute('title', srCaseIDString);
       
        await t
        .switchToIframe(iframeCase);
     
});

Thanks!

Aucun commentaire:

Enregistrer un commentaire