0

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;

        console.log(srCaseID);

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

Thanks!

Daniel
  • 5
  • 5

1 Answers1

1

innertext != innerText, it is case sensitive.

This works just fine:

const elementInnerText = await Selector('#id').innerText;
console.log(elementInnerText);
pavelsaman
  • 4,242
  • 1
  • 6
  • 25
  • Thank you for pointing out the case sensitive issue. But I receive the error: TypeError: console.log is not a function. When running the test. So I'm still not able of console logging the value of the selector. – Daniel Jan 29 '21 at 11:30
  • 1
    Does something here solve your problem https://stackoverflow.com/questions/31013221/typeerror-console-log-is-not-a-function ? Like putting a semicolon there after the statement, or making sure you don't define console variable anywhere else. – pavelsaman Jan 29 '21 at 12:03
  • Oh damn, I did define a console variable somewhere else. In a different file that I import in this test. Thank you very much for pointing that out! :) – Daniel Jan 29 '21 at 13:19