vendredi 23 mars 2018

Utilizing a simple web page test with Selenium Webdriver JS?

Minimal experience with automated testing. Gone through a fair amount of Selenium crash courses, but I seem to not understand how to utilize Selenium properly to begin with.

I'm sure there's much wrong with my code but here's what I've got so far: Using Chromedriver Javascript Don't understand the basic difference between the use of promises v. callbacks

Feedback I've received: My code is automating a lot of clicks but not testing to see if anything's actually passing or failing - just clicking stuff doesn't tell me anything if I'm not checking the result.

/*
* Navigate landing page
*/
 
"use strict";
 
var webdriver = require('selenium-webdriver');
var browser = new webdriver.Builder().usingServer().withCapabilities({'browserName': 'chrome' }).build();


function clickLink(link) {
    link.click();
}


 /* open demo page */
browser.get('https://demo.illuminateed.com');

/* test next button */
browser.findElement(webdriver.By.name('button_next')).click();

/* test forgot pass */
browser.findElement(webdriver.By.css('[href="?SisForgotPassword"]')).click();

/* return to landing page */
browser.executeScript("window.history.go(-1)");

/* test fb link */
browser.findElement(webdriver.By.css('[href="http://www.facebook.com/illuminateeducation"]')).click();

/* shift focus to fb tab, close, refocus on demo page */
browser.getAllWindowHandles().then(function (handles) {
    browser.driver.switchTo().window(handles[1]);
    browser.driver.close();
    browser.driver.switchTo().window(handles[0]);
});

/* shift focus to twitter tab, close, refocus on demo page */
browser.findElement(webdriver.By.css('[href="https://twitter.com/IlluminateEd"]')).click();
browser.getAllWindowHandles().then(function (handles) {
    browser.driver.switchTo().window(handles[1]);
    browser.driver.close();
    browser.driver.switchTo().window(handles[0]);
});

/* shift focus to twitter tab, close, refocus on demo page */
browser.findElement(webdriver.By.css('[href="https://twitter.com/IlluminateOps"]')).click();
browser.getAllWindowHandles().then(function (handles) {
    browser.driver.switchTo().window(handles[1]);
    browser.driver.close();
    browser.driver.switchTo().window(handles[0]);
});

/* test release notes link */
browser.findElement(webdriver.By.css('[href="https://support.illuminateed.com/hc/en-us/articles/360002018714-Release-Notes-v10-1"]')).click();
browser.executeScript("window.history.go(-1)");

/* test march 21 webinar link */
browser.findElement(webdriver.By.css('[href="https://attendee.gotowebinar.com/register/6711803094711305219?source=ATD"]')).click();
browser.executeScript("window.history.go(-1)");

/* test customer product info link */
browser.findElement(webdriver.By.css('[href="http://go.illuminateed.com/preferences"]')).click();
browser.executeScript("window.history.go(-1)");

/* test monthly learning link */
browser.findElement(webdriver.By.css('[href="http://go.illuminateed.com/monthlylearning"]')).click();
browser.executeScript("window.history.go(-1)");

/* test first help doc link */
browser.findElement(webdriver.By.css('[href="https://support.illuminateed.com/hc/en-us/articles/360001575874-Monitoring-Progress-on-Online-Assessments-General-and-Live-Proctoring"]')).click();
browser.executeScript("window.history.go(-1)");

/* test second webinar link */
browser.findElement(webdriver.By.css('[href="http://gslink.illuminateed.net/wf/click?upn=SG5vk6r1WQKpKzCWoPdii1zZGRu9fVv9snsWyve96BhU-2Bmnjq-2FtKcwBPLg4G-2Fbh7_iYfQllYcpyWEwczIM1abNM1HcsreBx6p8svHgJyjnhzt-2FOE2nA3VuPOTfyCZVv6mwu8ln6Nt1aRBqWNsGiTMyjKOH6qz5RLFxpT1Ci4ORqhcci3ztIOHsvlbPQkXF00HiF043ATKVbCt4PgANUJvn4myOMEb3rOIatUpC4BcDNXZzjy093QpH0IJv304AHborhaAg3OjS8Fny71s6UAMpwl4NKEqHa7Sne-2FiXza2qO1KYmJSlRFtKKKGfo8r93n9dPCs5DiNArsXyxW2YHVuR68IR4d74NWzI2s9pXNRJIfbByc5hz8Oo-2FV-2BjqJiqmgpW40k0REYdtmrEBthP568I5uNCKQShkdTLDtVJ0cAIO1AnZBhjAaZJ-2BceN8brgexx7QXJxtDgQWNtshOHuJgZKii3zrKBU3nZSRhqJJiIPlvrck1vd21VSjjbogQH4kKhTqwnk2VwTNJAStoSBvafZ09eSCp14-2BCzooyayDPAVHKuS0RYLMRDYNUvPr76euJ6"]')).click();
browser.executeScript("window.history.go(-1)");

/* test PFT link */
browser.findElement(webdriver.By.css('[href="https://www.cde.ca.gov/ta/tg/pf/"]')).click();
browser.executeScript("window.history.go(-1)");

/* test second help docs link */
browser.findElement(webdriver.By.css('[href="https://support.illuminateed.com/hc/en-us/sections/360000052314-Physical-Fitness-Testing"]')).click();
browser.executeScript("window.history.go(-1)");

/* test flyer link */
browser.findElement(webdriver.By.css('[href="http://go.illuminateed.com/pft"]')).click();
browser.executeScript("window.history.go(-1)");

/* test psat student summ link */
browser.findElement(webdriver.By.css('[href="https://support.illuminateed.com/hc/en-us/articles/360001114333-PSAT-SAT-Student-Summary"]')).click();
browser.executeScript("window.history.go(-1)");

/* test psat student roster link */
browser.findElement(webdriver.By.css('[href="https://support.illuminateed.com/hc/en-us/articles/360001114353-PSAT-SAT-Student-Roster"]')).click();
browser.executeScript("window.history.go(-1)");

/* test psat performance summ link */
browser.findElement(webdriver.By.css('[href="https://support.illuminateed.com/hc/en-us/articles/360001130594-PSAT-SAT-Performance-Summary"]')).click();
browser.executeScript("window.history.go(-1)");

/* test special events link */
browser.findElement(webdriver.By.css('[href="https://www.eventbrite.com/e/illuminate-education-equity-symposium-bay-area-tickets-37950545102?aff=ATD"]')).click();
browser.executeScript("window.history.go(-1)");

/* test upcoming webinars link */
browser.findElement(webdriver.By.css('[href="https://www.illuminateed.com/resources/"]')).click();
browser.executeScript("window.history.go(-1)");

Aucun commentaire:

Enregistrer un commentaire