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!
question from:
https://stackoverflow.com/questions/65951633/testcafe-console-log-the-value-of-a-selector 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…