Sitespeed – a script to wait for text

var waiting_text="Basic Data";
        var max_waiting_time=30;//seconds
        for(i=0;i<max_waiting_time;i++)
        {
            body_text= await driver.findElement(webdriver.By.tagName("body")).getText();
            if(body_text.includes(waiting_text))
            {
                console.log("Found required text["+waiting_text+"] at the "+i+"th seconds, exiting the waiting ");
                break;
            }else{
                await commands.wait.byTime(1000);
            }
        }
        if(i>=max_waiting_time)
        {
            console.log("Coul not find text["+waiting_text+"] at the "+i+"th seconds, exiting the waiting ");
        }

Leave a Reply

Your email address will not be published. Required fields are marked *