Reputation: 1
I'm currently using UDEMY to teach myself WebDriverIO. At the moment I'm in the fundamental stages of my journey. While watching a course I seem to have stumbled upon a problem. - I'm currently trying to have my code load up craigslist, pause for x amount of time, then notify me of any 'li' on the webpage. my code is able to find the website but it isn't able to find a 'li' on the website. any suggestions as to why my code doesn't work?
it('Load example Website', () => {
browser.url('https://www.example.com');
browser.pause(10000);
expect(browser).toHaveUrl('https://www.example.com');
});
describe('Craigslist website loads up', () => {
it('load Craigslist ', () => {
browser.url('https://minneapolis.craigslist.org/');
browser.pause(20000);
expect(browser).toHaveUrl('https://minneapolis.craigslist.org/');
expect(browser).toHaveTitle('craigslist');
});
});
it('Craigslist website, li should be visible', () => {
// GET Selector and save it to a variable
// do assertion
const li = $('li');
expect(li).toBeVisible();
});
});
Upvotes: 0
Views: 134
Reputation: 8352
Every test is and should be independent, that is you are not on any site in this test:
it('Craigslist website, li should be visible', () => {
const li = $('li');
expect(li).toBeVisible();
});
You need to go to the site like you do in the previous two tests.
Better way is to use beforeTest hook.
Upvotes: 1