Hello guys I try web scraping with Cypress. I want to take a letter from a website and re type it in the same web site but I get an error.
I get this error:[1]: https://i.stack.imgur.com/5LDMG.png
This is my code:
const { cwd } = require("process");
require("cypress-xpath");
// script.js created with Cypress
//
// Start writing your Cypress tests below!
// If you're unfamiliar with how Cypress works,
// check out the link below and learn how to write your first test:
// https://on.cypress.io/writing-first-test
//submit '//*[@id="login-form"]/div[3]/input'
//password '//*[@id="LoginForm_pw"]'
//username '//*[@id="LoginForm_username"]'
describe("My First Test", () => {
it("Visits the Kitchen Sink", () => {
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
var newWebsite = "https://at4.typewriter.at/index.php?r=typewriter/runLevel"
cy.visit("https://at4.typewriter.at/");
//__________________________________\\
//____________________________________\\
cy.get("#LoginForm_username").type("dasda");
cy.get("#LoginForm_pw").type("asdasd");
cy.xpath('//*[@id="login-form"]/div[3]/input').click();
cy.wait(3000);
cy.visit(newWebsite);
function loop() {
let actualLetter = cy.xpath('//*[@id="actualLetter"]').text;
if (actualLetter!=undefined){
cy.xpath('//*[@id="textInput"]').type(actualLetter);
}
setInterval(loop, 1000);
}
loop();
});
});