How to use driver.findElement method in ava

Best JavaScript code snippet using ava

selenium-test.js

Source:selenium-test.js Github

copy

Full Screen

...18 const driver = new Builder().forBrowser('chrome').build();19 it('/login should return an empty email (username) field', async function() {20 await driver.get(loginURL);21 await driver.sleep(2000);22 const loginField = await driver.findElement(By.name('uname')).getAttribute('value');23 expect(loginField).to.equal('');24 });25 it('/login should return an empty password field', async function() {26 await driver.get(loginURL);27 await driver.sleep(2000);28 const passwordField = await driver.findElement(By.name('pwd')).getAttribute('value');29 expect(passwordField).to.equal('');30 })31 it('should return the authentication error page with an empty password and empty email field', async function() {32 await driver.get(loginURL);33 await driver.sleep(2000);34 await driver.findElement(By.id('loginSubmit')).click();35 const failEmailField = await driver.findElement(By.name('uname')).getAttribute('value');36 const failPassField = await driver.findElement(By.name('pwd')).getAttribute('value');37 const errorMessage = await driver.findElement(By.css("p")).getText();38 const curURL = await driver.getCurrentUrl();39 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/loginfail');40 expect(failEmailField).to.equal('');41 expect(failPassField).to.equal('');42 expect(errorMessage).to.equal('Authentication error (incorrect email or password).');43 });44 it('should return the authentication error page with valid-formatted but not-in-database email and empty password', async function() {45 await driver.get(loginURL);46 await driver.sleep(2000);47 await driver.findElement(By.name('uname')).sendKeys('notAValid@Email');48 await driver.findElement(By.id('loginSubmit')).click();49 const failEmailField = await driver.findElement(By.name('uname')).getAttribute('value');50 const failPassField = await driver.findElement(By.name('pwd')).getAttribute('value');51 const errorMessage = await driver.findElement(By.css("p")).getText();52 const curURL = await driver.getCurrentUrl();53 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/loginfail');54 expect(failEmailField).to.equal('');55 expect(failPassField).to.equal('');56 expect(errorMessage).to.equal('Authentication error (incorrect email or password).');57 });58 it('should return the authentication error page with empty email and something in password field', async function() {59 await driver.get(loginURL);60 await driver.sleep(2000);61 await driver.findElement(By.name('pwd')).sendKeys('v3ryStr0ngPa55');62 await driver.findElement(By.id('loginSubmit')).click();63 const failEmailField = await driver.findElement(By.name('uname')).getAttribute('value');64 const failPassField = await driver.findElement(By.name('pwd')).getAttribute('value');65 const errorMessage = await driver.findElement(By.css("p")).getText();66 const curURL = await driver.getCurrentUrl();67 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/loginfail');68 expect(failEmailField).to.equal('');69 expect(failPassField).to.equal('');70 expect(errorMessage).to.equal('Authentication error (incorrect email or password).');71 });72 it('should return the authentication error page with incorrect email and incorrect password', async function() {73 await driver.get(loginURL);74 await driver.sleep(2000);75 await driver.findElement(By.name('uname')).sendKeys('invalidEmail@bgcengineering.ca');76 await driver.findElement(By.name('pwd')).sendKeys('v3ryStr0ngPa55');77 await driver.findElement(By.id('loginSubmit')).click();78 const failEmailField = await driver.findElement(By.name('uname')).getAttribute('value');79 const failPassField = await driver.findElement(By.name('pwd')).getAttribute('value');80 const errorMessage = await driver.findElement(By.css("p")).getText();81 const curURL = await driver.getCurrentUrl();82 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/loginfail');83 expect(failEmailField).to.equal('');84 expect(failPassField).to.equal('');85 expect(errorMessage).to.equal('Authentication error (incorrect email or password).');86 });87 it('should return the landing page (/main) for a correctly authenticated organizer user', async function() {88 await driver.get(loginURL);89 await driver.sleep(2000);90 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');91 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');92 await driver.findElement(By.id('loginSubmit')).click();93 const curURL = await driver.getCurrentUrl();94 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/main');95 await driver.get(logoutURL);96 });97 it('should return the landing page (/main) for a correctly authenticated attendee user', async function() {98 await driver.get(loginURL);99 await driver.sleep(2000);100 await driver.findElement(By.name('uname')).sendKeys('test-attendee@bgcengineering.ca');101 await driver.findElement(By.name('pwd')).sendKeys('11111111aA');102 await driver.findElement(By.id('loginSubmit')).click();103 const curURL = await driver.getCurrentUrl();104 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/main');105 await driver.get(logoutURL);106 });107 it('should return the login page after logging out');108 describe('main-menu', function() {109 it('sidebar should contain three elements for attendee user', async function() {110 await driver.get(loginURL);111 await driver.sleep(1000);112 await driver.findElement(By.name('uname')).sendKeys('test-attendee@bgcengineering.ca');113 await driver.findElement(By.name('pwd')).sendKeys('11111111aA');114 await driver.findElement(By.id('loginSubmit')).click();115 const links = await driver.findElements(By.className('nav-item'));116 await driver.get(logoutURL);117 expect(links.length).to.equal(3);118 });119 it('sidebar should contain four elements for organizer user', async function() {120 await driver.get(loginURL);121 await driver.sleep(1000);122 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');123 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');124 await driver.findElement(By.id('loginSubmit')).click();125 await driver.sleep(1000);126 const links = await driver.findElements(By.className('nav-item'));127 await driver.get(logoutURL);128 expect(links.length).to.equal(4);129 });130 it('on organizer nav, clicking second button should return to /organizer/main', async function() {131 await driver.get(loginURL);132 await driver.sleep(1000);133 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');134 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');135 await driver.findElement(By.id('loginSubmit')).click();136 await driver.findElement(By.id('returnToMain')).click();137 const curURL = await driver.getCurrentUrl();138 await driver.get(logoutURL);139 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/organizer/main');140 });141 it('on organizer nav, clicking third button should go to /organizer/allusers (user config page)', async function() {142 await driver.get(loginURL);143 await driver.sleep(1000);144 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');145 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');146 await driver.findElement(By.id('loginSubmit')).click();147 await driver.findElement(By.id('allusers')).click();148 const curURL = await driver.getCurrentUrl();149 await driver.get(logoutURL);150 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/organizer/allusers');151 });152 it('on attendee nav, clicking second button should return to /main', async function() {153 await driver.get(loginURL);154 await driver.sleep(1000);155 await driver.findElement(By.name('uname')).sendKeys('test-attendee@bgcengineering.ca');156 await driver.findElement(By.name('pwd')).sendKeys('11111111aA');157 await driver.findElement(By.id('loginSubmit')).click();158 await driver.findElement(By.id('attendeeMain')).click();159 const curURL = await driver.getCurrentUrl();160 await driver.get(logoutURL);161 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/main');162 });163 });164 describe('courses', function() {165 //course creation166 describe('course-creation', function() {167 /*it('Attendees should get a 401 Unauthorized status if they try to create a course', async function() {168 await driver.get(loginURL);169 await driver.sleep(1000);170 await driver.findElement(By.name('uname')).sendKeys('test-attendee@bgcengineering.ca');171 await driver.findElement(By.name('pwd')).sendKeys('11111111aA');172 await driver.findElement(By.id('loginSubmit')).click();173 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');174 const message401 = driver.findElement(By.class('pre')).getText();175 expect(message401).to.equal('Unauthorized');176 await driver.get(logoutURL);177 });*/178 it('Setting the registration deadline in the past should prompt an alert', async function() {179 await driver.get(loginURL);180 await driver.sleep(1000);181 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');182 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');183 await driver.findElement(By.id('loginSubmit')).click();184 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');185 //dummy course data186 await driver.findElement(By.id('coursename')).sendKeys('Test Course');187 await driver.findElement(By.id('topic')).sendKeys('Test');188 await driver.findElement(By.id('capacity')).sendKeys('20');189 await driver.findElement(By.id('location')).sendKeys("Meeting Room");190 //April 19, 2020, 11:59 pm191 await driver.findElement(By.id('deadline')).sendKeys('2020\t0419');192 //April 20, 2020 (before this course started)193 //8 AM - 10 AM (legal time)194 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0420');195 await driver.findElement(By.id('startTime1')).sendKeys('08:00A');196 await driver.findElement(By.id('endTime1')).sendKeys('10:00A');197 await driver.findElement(By.id('submitButton')).click();198 await driver.sleep(1000);199 const error = await driver.switchTo().alert().getText();200 await driver.switchTo().alert().accept();201 expect(error).to.equal('Cannot schedule registration deadline in the past.');202 await driver.get(logoutURL);203 });204 it('Creating sessions out of chronological order should prompt an alert', async function() {205 await driver.get(loginURL);206 await driver.sleep(1000);207 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');208 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');209 await driver.findElement(By.id('loginSubmit')).click();210 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');211 //dummy course data212 await driver.findElement(By.id('coursename')).sendKeys('Test Course');213 await driver.findElement(By.id('topic')).sendKeys('Test');214 await driver.findElement(By.id('capacity')).sendKeys('20');215 await driver.findElement(By.id('location')).sendKeys("Meeting Room");216 //April 19, 2020, 11:59 pm217 await driver.findElement(By.id('deadline')).sendKeys('2020\t0820');218 //create session on September 1, 10 AM - 12 PM219 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0901');220 await driver.findElement(By.id('startTime1')).sendKeys('10:00A');221 await driver.findElement(By.id('endTime1')).sendKeys('12:00P');222 //create new session223 await driver.findElement(By.id('addSession')).click();224 //create session on August 31, 10 AM - 12 PM225 await driver.findElement(By.id('sessionDate2')).sendKeys('2020\t0831');226 await driver.findElement(By.id('startTime2')).sendKeys('10:00A');227 await driver.findElement(By.id('endTime2')).sendKeys('12:00P');228 await driver.findElement(By.id('submitButton')).click();229 await driver.sleep(1000);230 const error = await driver.switchTo().alert().getText();231 await driver.switchTo().alert().accept();232 expect(error).to.equal('Sessions should be scheduled in chronological order');233 await driver.get(logoutURL);234 });235 it('Creating sessions with overlapping times should prompt an alert', async function() {236 await driver.get(loginURL);237 await driver.sleep(1000);238 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');239 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');240 await driver.findElement(By.id('loginSubmit')).click();241 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');242 //dummy course data243 await driver.findElement(By.id('coursename')).sendKeys('Test Course');244 await driver.findElement(By.id('topic')).sendKeys('Test');245 await driver.findElement(By.id('capacity')).sendKeys('20');246 await driver.findElement(By.id('location')).sendKeys("Meeting Room");247 //August 20, 2020, 11:59 pm248 await driver.findElement(By.id('deadline')).sendKeys('2020\t0820');249 //create session on September 1, 10 AM - 12 PM250 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0901');251 await driver.findElement(By.id('startTime1')).sendKeys('10:00A');252 await driver.findElement(By.id('endTime1')).sendKeys('12:00P');253 //create new session on September 1, 11 AM - 1 PM254 await driver.findElement(By.id('addSession')).click();255 await driver.findElement(By.id('sessionDate2')).sendKeys('2020\t0901');256 await driver.findElement(By.id('startTime2')).sendKeys('11:00A');257 await driver.findElement(By.id('endTime2')).sendKeys('01:00P');258 await driver.findElement(By.id('submitButton')).click();259 const error = await driver.switchTo().alert().getText();260 await driver.switchTo().alert().accept();261 expect(error).to.equal('Sessions should not overlap (previous session must end before next session starts)');262 await driver.get(logoutURL);263 });264 it('Creating sessions with the end time before the start time should prompt an alert', async function() {265 await driver.get(loginURL);266 await driver.sleep(1000);267 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');268 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');269 await driver.findElement(By.id('loginSubmit')).click();270 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');271 //dummy course data272 await driver.findElement(By.id('coursename')).sendKeys('Test Course');273 await driver.findElement(By.id('topic')).sendKeys('Test');274 await driver.findElement(By.id('capacity')).sendKeys('20');275 await driver.findElement(By.id('location')).sendKeys("Meeting Room");276 //August 20, 2020, 11:59 pm277 await driver.findElement(By.id('deadline')).sendKeys('2020\t0820');278 //create session on September 1, 12 PM - 10 AM :thonk:279 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0901');280 await driver.findElement(By.id('startTime1')).sendKeys('12:00P');281 await driver.findElement(By.id('endTime1')).sendKeys('10:00A');282 await driver.findElement(By.id('submitButton')).click();283 const error = await driver.switchTo().alert().getText();284 await driver.switchTo().alert().accept();285 expect(error).to.equal('End time of course must be after the start');286 await driver.get(logoutURL);287 });288 it('Setting the registration deadline after the first session should prompt an alert', async function() {289 await driver.get(loginURL);290 await driver.sleep(1000);291 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');292 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');293 await driver.findElement(By.id('loginSubmit')).click();294 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');295 //dummy course data296 await driver.findElement(By.id('coursename')).sendKeys('Test Course');297 await driver.findElement(By.id('topic')).sendKeys('Test');298 await driver.findElement(By.id('capacity')).sendKeys('20');299 await driver.findElement(By.id('location')).sendKeys("Meeting Room");300 //September 11, 2020, 11:59 pm301 await driver.findElement(By.id('deadline')).sendKeys('2020\t0911');302 //create session on September 1, 10 AM - 12 PM303 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0901');304 await driver.findElement(By.id('startTime1')).sendKeys('10:00A');305 await driver.findElement(By.id('endTime1')).sendKeys('12:00P');306 await driver.findElement(By.id('submitButton')).click();307 const error = await driver.switchTo().alert().getText();308 await driver.switchTo().alert().accept();309 expect(error).to.equal('Cannot schedule registration deadline after the first course session.');310 await driver.get(logoutURL);311 });312 it('Successfully creating a new course will redirect back to the organizer main', async function() {313 await driver.get(loginURL);314 await driver.sleep(1000);315 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');316 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');317 await driver.findElement(By.id('loginSubmit')).click();318 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');319 //dummy course data320 await driver.findElement(By.id('coursename')).sendKeys('Test Course');321 await driver.findElement(By.id('topic')).sendKeys('Test');322 await driver.findElement(By.id('capacity')).sendKeys('20');323 await driver.findElement(By.id('location')).sendKeys("Meeting Room");324 //August 20, 2020, 11:59 pm325 await driver.findElement(By.id('deadline')).sendKeys('2020\t0820');326 //create session on September 1, 10 AM - 12 PM327 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0901');328 await driver.findElement(By.id('startTime1')).sendKeys('10:00A');329 await driver.findElement(By.id('endTime1')).sendKeys('12:00P');330 await driver.findElement(By.id('submitButton')).click();331 const curURL = await driver.getCurrentUrl();332 await driver.get(logoutURL);333 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/organizer/main');334 });335 });336 //course access337 describe('course-access', function() {338 //it('Users must be logged in to access a course path');339 //it('Accessing a non-existent course will return a status code')340 it('For a valid course, the title must show up', async function() {341 await driver.get(loginURL);342 await driver.sleep(1000);343 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');344 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');345 await driver.findElement(By.id('loginSubmit')).click();346 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/4');347 const title = driver.findElement(By.class('h1')).getText();348 await driver.get(logoutURL);349 expect(title).to.be.a('string').that.is.not.empty;350 });351 /*352 it('For a valid course, the topic must be present', async function() {353 await driver.get(loginURL);354 await driver.sleep(1000);355 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');356 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');357 await driver.findElement(By.id('loginSubmit')).click();358 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/4');359 const topic = await driver.findElement(By.id('topic')).getText();360 await driver.get(logoutURL);361 expect(topic).to.be.a('string').that.is.not.empty;362 });*/363 it("For a valid course, the location must be present", async function() {364 await driver.get(loginURL);365 await driver.sleep(1000);366 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');367 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');368 await driver.findElement(By.id('loginSubmit')).click();369 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/4');370 const location = await driver.findElement(By.id('location')).getText();371 await driver.get(logoutURL);372 expect(location).to.be.a('string').that.is.not.empty;373 });374 it("For a valid course, the maximum number of seats must be present", async function() {375 await driver.get(loginURL);376 await driver.sleep(1000);377 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');378 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');379 await driver.findElement(By.id('loginSubmit')).click();380 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/4');381 const seats = await driver.findElement(By.id('seatNum')).getText();382 await driver.get(logoutURL);383 expect(seats).to.be.a('string').that.is.not.empty;384 });385 it("For a valid course, there should be at least one session with indicated date, start, and end times")386 });387 //course editing388 describe('course-editing', function() {389 it('should render course information in the proper fields', async function() {390 await driver.get(loginURL);391 await driver.sleep(1000);392 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');393 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');394 await driver.findElement(By.id('loginSubmit')).click();395 await driver.get(orgMain);396 //important: make sure there is a course called "Test Course" that has been created397 await driver.findElement(By.linkText("Test Course")).click()398 const name = await driver.findElement(By.id('coursename')).getText()399 const capacity = parseInt(driver.findElement(By.id('capacity')).getText(), 10)400 const location = await driver.findElement(By.id('location')).getText();401 const deadDate = await driver.findElement(By.id('deadline')).getText();402 const deadTime = await driver.findElement(By.id('deadTime')).getText();403 const sessions = await driver.findElements(By.className('sessionRow'));404 await driver.get(logoutURL);405 expect(name).to.be.a('string').that.is.not.empty;406 expect(loaction).to.be.a('string').that.is.not.empty;407 expect(capacity).to.be.above(0);408 expect(deadDate).to.be.a('string').that.is.not.empty;409 expect(deadTime).to.be.a('string').that.is.not.empty;410 expect(sessions).to.have.lengthOf.at.least(1);411 });412 it('number of enrolled users should be less than or equal to the seat capacity', async function() {413 await driver.get(loginURL);414 await driver.sleep(1000);415 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');416 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');417 await driver.findElement(By.id('loginSubmit')).click();418 await driver.get(orgMain);419 //important: make sure there is a course called "Test Course" that has been created420 await driver.findElement(By.linkText("Test Course")).click();421 const enrolled = await driver.findElements(By.className('enrolledUsers'));422 const capacity = parseInt(driver.findElement(By.id('capacity')).getText(), 10);423 await driver.get(logoutURL)424 expect(enrolled.length).to.be.below(capacity)425 });426 it('when there is a waitlist, number of waitlisted users + number of enrolled users should be more than the seat capacity', async function() {427 await driver.get(loginURL);428 await driver.sleep(1000);429 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');430 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');431 await driver.findElement(By.id('loginSubmit')).click();432 await driver.get(orgMain);433 await driver.findElement(By.linkText("Waitlist Course")).click();434 const enrolled = await driver.findElements(By.className('enrolledUsers')).length;435 const waitlist = await driver.findElements(By.className('waitlistUsers')).length;436 const capacity = parseInt(driver.findElement(By.id('capacity')).getText(), 10);437 await driver.get(logoutURL);438 expect(waitlist + enrolled).to.be.above(capacity);439 });440 });441 describe('course-integration-testing', function() {442 it('creating a course without accepting registration should hide the course in /main. Enabling the course will allow registration, which increases the number of enrolled by 1', async function() {443 await driver.get(loginURL);444 await driver.sleep(1000);445 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');446 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');447 await driver.findElement(By.id('loginSubmit')).click();448 let initCourses = await driver.findElements(By.className('visibleCourses')).length;449 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');450 await driver.findElement(By.id('coursename')).sendKeys('Test Integration Course');451 //await driver.findElement(By.id('topic')).sendKeys('');452 await driver.findElement(By.id('capacity')).sendKeys('20');453 await driver.findElement(By.id('location')).sendKeys("Meeting Room");454 //August 20, 2020, 11:59 pm455 await driver.findElement(By.id('deadline')).sendKeys('2020\t0820');456 await driver.findElement(By.id('deadTime')).sendKeys('11:59P');457 //create session on September 2, 10 AM - 12 PM458 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0902');459 await driver.findElement(By.id('startTime1')).sendKeys('10:00A');460 await driver.findElement(By.id('endTime1')).sendKeys('12:00P');461 await driver.findElement(By.id('submitButton')).click();462 await driver.sleep(3000);463 await driver.get(attendeeMain);464 let shouldBeSame = await driver.findElements(By.className('visibleCourses')).length;465 await driver.get(orgMain);466 await driver.findElement(By.linkText('Test Integration Course')).click();467 await driver.findElement(By.name('registration')).click()468 await driver.findElement(By.id('submitButton')).click();469 await driver.sleep(3000);470 await driver.get(attendeeMain);471 let moreByOne = await driver.findElements(By.className('visibleCourses')).length;472 //delete the course473 await driver.get(orgMain);474 await driver.findElement(By.linkText('Test Integration Course')).click();475 await driver.findElement(By.name('delCourse')).click();476 await driver.switchTo().alert().sendKeys('Please delete this course.');477 await driver.switchTo().alert().accept();478 await driver.sleep(4000);479 const testURL = await driver.getCurrentUrl();480 await driver.get(logoutURL);481 expect(initCourses).to.equal(shouldBeSame);482 expect(moreByOne).to.be.above(initCourses);483 expect(testURL).to.equal(orgMain);484 });485 it('Creating a 1-seat course, enrolling, enrolling a separate user, withdrawing the original user, then attempting to enroll the original user will result in that user put on the waitlist', async function() {486 await driver.get(loginURL);487 await driver.sleep(1000);488 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');489 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');490 await driver.findElement(By.id('loginSubmit')).click();491 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/new');492 await driver.findElement(By.id('coursename')).sendKeys('Waitlist Bop Course');493 //await driver.findElement(By.id('topic')).sendKeys('');494 await driver.findElement(By.id('capacity')).sendKeys('1');495 await driver.findElement(By.id('location')).sendKeys("Meeting Room");496 //August 20, 2020, 11:59 pm497 await driver.findElement(By.id('deadline')).sendKeys('2020\t0820');498 await driver.findElement(By.id('deadTime')).sendKeys('11:59P');499 //create session on September 2, 10 AM - 12 PM500 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0902');501 await driver.findElement(By.id('startTime1')).sendKeys('10:00A');502 await driver.findElement(By.id('endTime1')).sendKeys('12:00P');503 await driver.findElement(By.name('registration')).click();504 await driver.findElement(By.id('submitButton')).click();505 await driver.sleep(4000);506 await driver.findElement(By.linkText('Waitlist Bop Course')).click();507 const buttonText1 = await driver.findElement(By.id('submitButton')).getText();508 await driver.findElement(By.id('submitButton')).click();509 await driver.sleep(4000);510 await driver.get(logoutURL);511 await driver.sleep(4000);512 await driver.findElement(By.name('uname')).sendKeys('test-attendee@bgcengineering.ca');513 await driver.findElement(By.name('pwd')).sendKeys('11111111aA');514 await driver.findElement(By.id('loginSubmit')).click();515 await driver.findElement(By.linkText('Waitlist Bop Course')).click();516 const buttonText2 = await driver.findElement(By.id('submitButton')).getText();517 await driver.findElement(By.id('submitButton')).click();518 await driver.sleep(4000);519 await driver.get(logoutURL);520 await driver.sleep(4000);521 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');522 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');523 await driver.findElement(By.id('loginSubmit')).click();524 await driver.findElement(By.linkText('Waitlist Bop Course')).click();525 const buttonText3 = await driver.findElement(By.id('submitButton')).getText();526 await driver.findElement(By.id('submitButton')).click();527 await driver.sleep(4000);528 await driver.findElement(By.linkText('Waitlist Bop Course')).click();529 const buttonText4 = await driver.findElement(By.id('submitButton')).getText();530 await driver.findElement(By.id('submitButton')).click();531 const redirectText = await driver.findElement(By.id('redirectMessage')).getText();532 await driver.sleep(4000);533 await driver.get(logoutURL);534 expect(buttonText1).to.equal("Enroll");535 expect(buttonText2).to.equal("Enroll");536 expect(buttonText3).to.equal("Withdraw");537 expect(buttonText4).to.equal("Enroll");538 expect(redirectText).to.equal("Added to waitlist for this course. You will be notified if you move off the waitlist. You will be redirected to the main page.");539 });540 });541 describe('course-enrollment', function() {542 it('when not enrolled, there should be an enroll button', async function() {543 await driver.get(loginURL);544 await driver.sleep(2000);545 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');546 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');547 await driver.findElement(By.id('loginSubmit')).click();548 await driver.findElement(By.linkText('Enrollment Test Course'));549 const buttonText = await driver.findElement(By.id('submitButton')).getText();550 await driver.get(logoutURL);551 expect(buttonText).to.equal('Enroll')552 });553 it('when enrolled, the button should be a withdraw button', async function() {554 await driver.get(loginURL);555 await driver.sleep(2000);556 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');557 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');558 await driver.findElement(By.id('loginSubmit')).click();559 await driver.findElement(By.linkText('Enrollment Test Course')).click();560 await driver.findElement(By.id('submitButton')).click();561 await driver.sleep(4000);562 const testURL = await driver.getCurrentUrl();563 await driver.findElement(By.linkText('Enrollment Test Course')).click();564 const buttonText = await driver.findElement(By.id('submitButton')).getText();565 await driver.get(logoutURL);566 expect(buttonText).to.equal('Withdraw');567 expect(testURL).to.equal(attMain);568 });569 })570 // email paths571 describe('no-users-enrolled', async () => {572 await driver.get(loginURL);573 await driver.sleep(20000);574 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');575 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');576 await driver.findElement(By.id('loginSubmit')).click();577 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/23');578 await driver.findElement(By.id('emailConf')).click();579 await driver.findElement(By.id('emailSendSubmit')).click();580 const message = await driver.findElement(By.id('redirectMessage')).getText();581 await driver.get(logoutURL);582 expect(message).to.equal('No users enrolled, no emails sent. You will be redirected to the course view.');583 });584 describe('email-success', async () => {585 await driver.get(loginURL);586 await driver.sleep(20000);587 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');588 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');589 await driver.findElement(By.id('loginSubmit')).click();590 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/23');591 await driver.findElement(By.id('emailConf')).click();592 await driver.findElement(By.id('emailSendSubmit')).click();593 const message = await driver.findElement(By.id('redirectMessage')).getText();594 await driver.get(logoutURL);595 expect(message).to.equal('Email sent successfully! You will be redirected to the course view.');596 });597 // a true failure will result in an instance when the api fails and throws an err598 // a case where this happens is if the api key is messing599 // to test remove the api key600 // describe('email-api-fail', () => {601 // await driver.get(loginURL);602 // await driver.sleep(20000);603 // await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');604 // await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');605 // await driver.findElement(By.id('loginSubmit')).click();606 // await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/24');607 // await driver.findElement(By.id('emailConf')).click();608 // await driver.findElement(By.id('emailSendSubmit')).click();609 // const message = await driver.findElement(By.id('redirectMessage')).getText();610 // await driver.get(logoutURL);611 // expect(message).to.equal('ERROR: EMAIL NOT SENT! API failure. You will be redirected to the course view.');612 // });613 describe('disable-user', async () => {614 await driver.get(loginURL);615 await driver.sleep(20000);616 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');617 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');618 await driver.findElement(By.id('loginSubmit')).click();619 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/organizer/allusers');620 await driver.findElement(By.id('approvedFalse3')).click();621 await driver.findElement(By.name('updateUserData')).click();622 const message = await driver.findElement(By.id('redirectMessage')).getText();623 await driver.get(logoutURL);624 expect(message).to.equal('User data has been successfully updated! You will be redirected to the main courses page.');625 await driver.get(loginURL);626 await driver.findElement(By.name('uname')).sendKeys('mla283@sfu.ca');627 await driver.findElement(By.name('pwd')).sendKeys('Password123!');628 await driver.findElement(By.id('loginSubmit')).click();629 const curURL = await driver.getCurrentUrl();630 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/login');631 });632 describe('approve-user', async () => {633 await driver.get(loginURL);634 await driver.sleep(20000);635 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');636 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');637 await driver.findElement(By.id('loginSubmit')).click();638 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/organizer/allusers');639 await driver.findElement(By.id('approvedTrue3')).click();640 await driver.findElement(By.name('updateUserData')).click();641 const message = await driver.findElement(By.id('redirectMessage')).getText();642 await driver.get(logoutURL);643 expect(message).to.equal('User data has been successfully updated! You will be redirected to the main courses page.');644 await driver.get(loginURL);645 await driver.findElement(By.name('uname')).sendKeys('mla283@sfu.ca');646 await driver.findElement(By.name('pwd')).sendKeys('Password123!');647 await driver.findElement(By.id('loginSubmit')).click();648 const curURL = await driver.getCurrentUrl();649 expect(curURL).to.equal('https://cmpt276-bgc-coursys.herokuapp.com/main');650 // should check mla283@sfu.ca's inbox to see email received651 });652 653 describe('add-tags', async () => {654 await drive.get(loginURL);655 await (await driver).sleep(20000);656 657 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');658 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');659 await driver.findElement(By.id('loginSubmit')).click();660 661 await driver.get('http://cmpt276-bgc-coursys.herokuapp.com/courses/new');662 663 //dummy course data664 await driver.findElement(By.id('coursename')).sendKeys('Test Course');665 await driver.findElement(By.id('topic')).sendKeys('Test');666 await driver.findElement(By.id('capacity')).sendKeys('20');667 await driver.findElement(By.id('location')).sendKeys("Meeting Room");668 669 //August 20, 2020, 11:59 pm670 await driver.findElement(By.id('deadline')).sendKeys('2020\t0820');671 672 //create session on September 1, 10 AM - 12 PM673 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0901');674 await driver.findElement(By.id('startTime1')).sendKeys('10:00A');675 await driver.findElement(By.id('endTime1')).sendKeys('12:00P');676 await driver.findElement(By.id('tags')).sendKeys('leadership');677 678 await driver.findElement(By.id('submitButton')).click();679 680 await driver.get('http://cmpt276-bgc-coursys.herokuapp.com/main');681 const message = await driver.findElement(By.id('5tags')).getText();682 683 await driver.get(logoutURL);684 685 expect(message2).to.equal('leadership');686 687 });688 689 690 describe('get-status', async () => {691 await drive.get(loginURL);692 await (await driver).sleep(20000);693 694 await driver.findElement(By.name('uname')).sendKeys('test-organizer@bgcengineering.ca');695 await driver.findElement(By.name('pwd')).sendKeys('teamBPtestpassword1');696 await driver.findElement(By.id('loginSubmit')).click();697 await driver.get('http://cmpt276-bgc-coursys.herokuapp.com/courses/new');698 699 //dummy course data700 await driver.findElement(By.id('coursename')).sendKeys('Small Course');701 await driver.findElement(By.id('topic')).sendKeys('Test');702 await driver.findElement(By.id('capacity')).sendKeys('1');703 await driver.findElement(By.id('location')).sendKeys("Meeting Room");704 705 //August 20, 2020, 11:59 pm706 await driver.findElement(By.id('deadline')).sendKeys('2020\t0820');707 708 //create session on September 1, 10 AM - 12 PM709 await driver.findElement(By.id('sessionDate1')).sendKeys('2020\t0901');710 await driver.findElement(By.id('startTime1')).sendKeys('10:00A');711 await driver.findElement(By.id('endTime1')).sendKeys('12:00P');712 await driver.findElement(By.id('tags')).sendKeys('leadership');713 714 await driver.findElement(By.id('submitButton')).click();715 716 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/6');717 718 await driver.findElement(By.id('enroll'))719 720 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/main');721 const message = await driver.findElement(By.id('6status')).getText();722 723 await driver.get(logoutURL);724 725 expect(message).to.equal('Enrolled');726 727 await drive.get(loginURL);728 729 await driver.findElement(By.name('uname')).sendKeys('mla283@sfu.ca');730 await driver.findElement(By.name('pwd')).sendKeys('Password123!');731 await driver.findElement(By.id('loginSubmit')).click();732 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/courses/6');733 734 await driver.findElement(By.id('enroll'))735 736 await driver.get('https://cmpt276-bgc-coursys.herokuapp.com/main');737 const message2 = await driver.findElement(By.id('6status')).getText();738 const message3 = await driver.findElement(By.id('6seats')).getText();739 740 await driver.get(logoutURL);741 742 expect(message2).to.equal('Waitlisted');743 expect(message3).to.equal('2/1 [1]');744 });745});746after(async () => driver.quit());...

Full Screen

Full Screen

e2e.test.js

Source:e2e.test.js Github

copy

Full Screen

...89 const txElementArray = await driver.findElements(By.css('#tx-pending > div'));90 return txElementArray.length;91}92async function isElementDisplayed(pageId) {93 return driver.findElement(By.id(pageId))94 .isDisplayed();95}96async function isPageCreateAccount() {97 return isElementDisplayed('create-acc-page');98}99async function isPageLogin() {100 return isElementDisplayed('login-page');101}102async function isPageUser() {103 return isElementDisplayed('user-page');104}105async function isTabTransactions() {106 return isElementDisplayed('tab-tx');107}108async function isTabSettings() {109 return isElementDisplayed('tab-settings');110}111describe('create account', () => {112 beforeAll(async () => {113 ({114 driver,115 popupUri,116 } = await setupBrowser());117 });118 beforeEach(async () => {119 // open popup120 await driver.get(popupUri);121 expect(await isPageCreateAccount())122 .toBeTruthy();123 });124 afterEach(async () => {125 await clearStore();126 });127 afterAll(async () => {128 await driver.quit();129 });130 test('create account and login', async () => {131 expect.assertions(4);132 // input password for new account133 await driver.findElement(By.id('password-new'))134 .sendKeys(password);135 await driver.findElement(By.id('password-new-confirm'))136 .sendKeys(password);137 // create account button138 await driver.findElement(By.id('btn-create-acc'))139 .click();140 // check if account was created141 const decrypted = await getEncryptedStoreDataByKey(STORE_KEY_VAULT, password);142 expect(decrypted)143 .toBe('{}');144 expect(await isPageUser())145 .toBeTruthy();146 // default tab is tx tab147 expect(await isTabTransactions())148 .toBeTruthy();149 });150 test('create account with invalid password', async () => {151 expect.assertions(4);152 const invalidPassword = '';153 // input password for new account154 await driver.findElement(By.id('password-new'))155 .sendKeys(invalidPassword);156 await driver.findElement(By.id('password-new-confirm'))157 .sendKeys(invalidPassword);158 // create account button159 await driver.findElement(By.id('btn-create-acc'))160 .click();161 // check if account was created162 expect(await getStoreDataByKey(STORE_KEY_VAULT))163 .toBeUndefined();164 expect(await isPageUser())165 .toBeFalsy();166 // default tab is tx tab167 expect(await isTabTransactions())168 .toBeFalsy();169 });170 test('create account with not matching passwords', async () => {171 expect.assertions(4);172 // input password for new account173 await driver.findElement(By.id('password-new'))174 .sendKeys('asdfasdfasdf1');175 await driver.findElement(By.id('password-new-confirm'))176 .sendKeys('asdfasdfasdf2');177 // create account button178 await driver.findElement(By.id('btn-create-acc'))179 .click();180 // check if account was created181 expect(await getStoreDataByKey(STORE_KEY_VAULT))182 .toBeUndefined();183 expect(await isPageUser())184 .toBeFalsy();185 // default tab is tx tab186 expect(await isTabTransactions())187 .toBeFalsy();188 });189});190describe('log in', () => {191 beforeAll(async () => {192 ({193 driver,194 popupUri,195 } = await setupBrowser());196 // create account197 await driver.get(popupUri);198 const data = {};199 await setEncryptedStoreDataByKey(STORE_KEY_VAULT, data, password);200 });201 beforeEach(async () => {202 // open popup203 await driver.get(popupUri);204 expect(await isPageLogin())205 .toBeTruthy();206 });207 afterAll(async () => {208 await driver.quit();209 });210 test('log in with valid credentials, then logout', async () => {211 expect.assertions(5);212 /**213 * Login214 */215 // input password216 await driver.findElement(By.id('password'))217 .sendKeys(password);218 // log in button219 await driver.findElement(By.id('btn-login'))220 .click();221 expect(await isPageUser())222 .toBeTruthy();223 /**224 * Logout225 */226 // switch to settings tab227 await driver.findElement(By.xpath('//button[@value="tab-settings"]'))228 .click();229 expect(await isPageUser())230 .toBeTruthy();231 expect(await isTabSettings())232 .toBeTruthy();233 // log out button234 await driver.findElement(By.id('btn-logout'))235 .click();236 expect(await isPageLogin())237 .toBeTruthy();238 });239 test('log in with invalid credentials', async () => {240 expect.assertions(2);241 const invalidPassword = 'sdfgsdfgsdfgsdfg';242 // input password243 await driver.findElement(By.id('password'))244 .sendKeys(invalidPassword);245 // log in button246 await driver.findElement(By.id('btn-login'))247 .click();248 expect(await isPageUser())249 .not250 .toBeTruthy();251 });252});253describe('import key', () => {254 beforeAll(async () => {255 ({256 driver,257 popupUri,258 } = await setupBrowser());259 // create account260 await driver.get(popupUri);261 const data = {};262 await setEncryptedStoreDataByKey(STORE_KEY_VAULT, data, password);263 await driver.get(popupUri);264 // log in265 await driver.findElement(By.id('password'))266 .sendKeys(password);267 await driver.findElement(By.id('btn-login'))268 .click();269 await driver.findElement(By.xpath('//button[@value="tab-settings"]'))270 .click();271 });272 beforeEach(async () => {273 expect(await isPageUser())274 .toBeTruthy();275 expect(await isTabSettings())276 .toBeTruthy();277 });278 afterEach(async () => {279 await driver.findElement(By.id('imp-key-sk'))280 .clear();281 await driver.findElement(By.id('imp-key-pk'))282 .clear();283 await driver.findElement(By.id('imp-key-sg'))284 .clear();285 await driver.findElement(By.id('imp-key-password'))286 .clear();287 });288 afterAll(async () => {289 await driver.quit();290 });291 test('import valid key', async () => {292 expect.assertions(6);293 // input secret key294 await driver.findElement(By.id('imp-key-sk'))295 .sendKeys(secretKey);296 // input public key297 await driver.findElement(By.id('imp-key-pk'))298 .sendKeys(publicKey);299 // input signature300 await driver.findElement(By.id('imp-key-sg'))301 .sendKeys(signature);302 // input password303 await driver.findElement(By.id('imp-key-password'))304 .sendKeys(password);305 // import key button306 await driver.findElement(By.id('btn-imp-key'))307 .click();308 // check if form.js fields are empty - key was imported309 expect(await driver.findElement(By.id('imp-key-sk'))310 .getAttribute('value'))311 .toBe('');312 expect(await driver.findElement(By.id('imp-key-pk'))313 .getAttribute('value'))314 .toBe('');315 expect(await driver.findElement(By.id('imp-key-sg'))316 .getAttribute('value'))317 .toBe('');318 expect(await driver.findElement(By.id('imp-key-password'))319 .getAttribute('value'))320 .toBe('');321 });322 test('import key with invalid signature', async () => {323 expect.assertions(6);324 const invalidSignature = '3523C65D4296455FCD3E07055F43C71872699558DD73A94BBD16C77852155FAE'325 + '0EF46E87AB3D8F86EDAC26A65BEE7B90AFFE7E0F8C592927475A66805F128509';326 // input secret key327 await driver.findElement(By.id('imp-key-sk'))328 .sendKeys(secretKey);329 // input public key330 await driver.findElement(By.id('imp-key-pk'))331 .sendKeys(publicKey);332 // input signature333 await driver.findElement(By.id('imp-key-sg'))334 .sendKeys(invalidSignature);335 // input password336 await driver.findElement(By.id('imp-key-password'))337 .sendKeys(password);338 // import key button339 await driver.findElement(By.id('btn-imp-key'))340 .click();341 // check if form.js fields are empty - key was imported342 expect(await driver.findElement(By.id('imp-key-sk'))343 .getAttribute('value'))344 .not345 .toBe('');346 expect(await driver.findElement(By.id('imp-key-pk'))347 .getAttribute('value'))348 .not349 .toBe('');350 expect(await driver.findElement(By.id('imp-key-sg'))351 .getAttribute('value'))352 .not353 .toBe('');354 expect(await driver.findElement(By.id('imp-key-password'))355 .getAttribute('value'))356 .not357 .toBe('');358 });359});360describe('positive path test', () => {361 beforeAll(async () => {362 ({363 driver,364 popupUri,365 } = await setupBrowser());366 });367 afterAll(async () => {368 await driver.quit();369 });370 test('create account and login', async () => {371 expect.assertions(4);372 // open popup373 await driver.get(popupUri);374 expect(await isPageCreateAccount())375 .toBeTruthy();376 // input password for new account377 await driver.findElement(By.id('password-new'))378 .sendKeys(password);379 await driver.findElement(By.id('password-new-confirm'))380 .sendKeys(password);381 // create account button382 await driver.findElement(By.id('btn-create-acc'))383 .click();384 // check if account was created385 const encrypted = await getStoreDataByKey(STORE_KEY_VAULT);386 const decrypted = CryptoJS.AES.decrypt(encrypted, password)387 .toString(CryptoJS.enc.Utf8);388 expect(decrypted)389 .toBe('{}');390 expect(await isPageUser())391 .toBeTruthy();392 // default tab is tx tab393 expect(await isTabTransactions())394 .toBeTruthy();395 });396 test('import key', async () => {397 expect.assertions(6);398 // switch to settings tab399 await driver.findElement(By.xpath('//button[@value="tab-settings"]'))400 .click();401 expect(await isPageUser())402 .toBeTruthy();403 expect(await isTabSettings())404 .toBeTruthy();405 // input secret key406 await driver.findElement(By.id('imp-key-sk'))407 .sendKeys(secretKey);408 // input public key409 await driver.findElement(By.id('imp-key-pk'))410 .sendKeys(publicKey);411 // input signature412 await driver.findElement(By.id('imp-key-sg'))413 .sendKeys(signature);414 // input password415 await driver.findElement(By.id('imp-key-password'))416 .sendKeys(password);417 // import key button418 await driver.findElement(By.id('btn-imp-key'))419 .click();420 // check if form.js fields are empty - key was imported421 expect(await driver.findElement(By.id('imp-key-sk'))422 .getAttribute('value'))423 .toBe('');424 expect(await driver.findElement(By.id('imp-key-pk'))425 .getAttribute('value'))426 .toBe('');427 expect(await driver.findElement(By.id('imp-key-sg'))428 .getAttribute('value'))429 .toBe('');430 expect(await driver.findElement(By.id('imp-key-password'))431 .getAttribute('value'))432 .toBe('');433 });434 test('log out', async () => {435 expect.assertions(3);436 // switch to settings tab437 await driver.findElement(By.xpath('//button[@value="tab-settings"]'))438 .click();439 expect(await isPageUser())440 .toBeTruthy();441 expect(await isTabSettings())442 .toBeTruthy();443 // log out button444 await driver.findElement(By.id('btn-logout'))445 .click();446 expect(await isPageLogin())447 .toBeTruthy();448 });449 test('add transaction', async () => {450 expect.assertions(1);451 // open test page452 await driver.get(`file:///${__dirname}/../index.html`);453 // add transaction454 await driver.findElement(By.id('btn-add-tx'))455 .click();456 // check if there are console errors457 const consoleErrorArray = await driver.manage()458 .logs()459 .get(logging.Type.BROWSER);460 console.log(consoleErrorArray);461 const errorCount = consoleErrorArray.length;462 expect(errorCount)463 .toBe(0);464 });465 test('log in', async () => {466 expect.assertions(2);467 // open popup468 await driver.get(popupUri);469 expect(await isPageLogin())470 .toBeTruthy();471 // input password472 await driver.findElement(By.id('password'))473 .sendKeys(password);474 // log in button475 await driver.findElement(By.id('btn-login'))476 .click();477 expect(await isPageUser())478 .toBeTruthy();479 });480 test('sign transaction', async () => {481 expect.assertions(3);482 // switch to transaction tab483 await driver.findElement(By.xpath('//button[@value="tab-tx"]'))484 .click();485 expect(await isTabTransactions())486 .toBeTruthy();487 expect(await getPendingTxCount())488 .toBe(1);489 // sign button490 await driver.findElement(By.className('btn-accept'))491 .click();492 expect(await getPendingTxCount())493 .toBe(0);494 });...

Full Screen

Full Screen

noCampusRunTW.js

Source:noCampusRunTW.js Github

copy

Full Screen

...50 //goes to website51 await driver.get(url);52 //first page (student login page)53 //gets boxes54 let usernameBox = await driver.findElement(By.name("username"));55 let pwBox = await driver.findElement(By.name("password"));56 //let submitBox = await driver.findElement(By.className("btn btn-primary"));57 //sets boxes values58 usernameBox.sendKeys(gvUsername);59 pwBox.sendKeys(gvPw,Key.ENTER);6061 await wait2s();62 url = await driver.getCurrentUrl();63 //checks what page is6465 if (url !== "https://www.gvsu.edu/hro/selfassessment-entry-edit.htm"){66 let new_assessment = await driver.findElement(By.css("#cms-content > p.selfassessment-nav > a.btn.btn-inverse"));67 new_assessment.click();68 await wait2s();69 url = await driver.getCurrentUrl();70 }7172 //for all questions below there are two objects per question with same name other than the ending73 //type Yes or No on it to select it that way7475 //actual assessment page76 //selection questions77 //tested in last thirty days (NO)78 //let testBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(2) > label > select > option:nth-child(2)"));79 //let testBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(2) > label > select > option:nth-child(3)"));80 //testBoxNo.click();81 //exposure to virus82 //let virusExposureBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(4) > label > select > option:nth-child(2)"));83 //let virusExposureBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(4) > label > select > option:nth-child(3)"));84 //virusExposureBoxNo.click();85 //be at gvsu campus today86 //let campusBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(2)"));87 //let campusBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(3)"));88 //campusBoxNo.click();8990 /*91 //clinical or internship92 let internBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(2)"));93 let internBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(3)"));94 internBoxNo.click();95 //isolation96 let isolationBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(9) > label > select > option:nth-child(4)"))97 isolationBoxNo.click();98 //outside michigan99 let michBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(10) > label > select > option:nth-child(2)"));100 let michBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(10) > label > select > option:nth-child(3)"));101 michBoxNo.click();102103 //yes or no questions104 //template105 //let noseBoxYes = await driver.findElement(By.css(""));106 //let noseBoxNo = await driver.findElement(By.css(""));107 //chills108 let chillBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(13) > span > label:nth-child(1) > input[type=radio]"));109 let chillBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(13) > span > label:nth-child(2) > input[type=radio]"))110 chillBoxNo.click();111 //runny nose112 let noseBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(14) > span > label:nth-child(1) > input[type=radio]"));113 let noseBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(14) > span > label:nth-child(2) > input[type=radio]"));114 noseBoxNo.click();115 //cough116 let coughBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(15) > span > label:nth-child(1) > input[type=radio]"));117 let coughBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(15) > span > label:nth-child(2) > input[type=radio]"));118 coughBoxNo.click();119 //nausea or diarrhea120 let sickBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(16) > span > label:nth-child(1) > input[type=radio]"));121 let sickBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(16) > span > label:nth-child(2) > input[type=radio]"));122 sickBoxNo.click();123 //tired124 let tiredBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(17) > span > label:nth-child(1) > input[type=radio]"));125 let tiredBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(17) > span > label:nth-child(2) > input[type=radio]"));126 tiredBoxNo.click();127 //fever128 let feverBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(18) > span > label:nth-child(1) > input[type=radio]"));129 let feverBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(18) > span > label:nth-child(2) > input[type=radio]"));130 feverBoxNo.click();131 //loss of taste or smell132 let lossBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(19) > span > label:nth-child(1) > input[type=radio]"));133 let lossBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(19) > span > label:nth-child(2) > input[type=radio]"));134 lossBoxNo.click();135 //muscle aches136 let musBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(20) > span > label:nth-child(1) > input[type=radio]"));137 let musBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(20) > span > label:nth-child(2) > input[type=radio]"));138 musBoxNo.click();139 //breath shortness140 let breathBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(21) > span > label:nth-child(1) > input[type=radio]"));141 let breathBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(21) > span > label:nth-child(2) > input[type=radio]"));142 breathBoxNo.click();143 //sore throat144 let throatBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(22) > span > label:nth-child(1) > input[type=radio]"));145 let throatBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(22) > span > label:nth-child(2) > input[type=radio]"));146 throatBoxNo.click();147 */148149 //Agree checkbox150 let agreeCheckBox = await driver.findElement(By.css("#consentWrapper > p:nth-child(4) > label > input[type=checkbox]"));151 agreeCheckBox.click();152153 //Signiture box154 let signitureBox = await driver.findElement(By.css("#consentWrapper > p:nth-child(5) > label > input[type=text]"));155 signitureBox.sendKeys("Tyler West");156157 //confirmation box158 //<input type="checkbox" name="isConfirmed" value="1" required="true" message="Please indicate you have confirmed your responses prior to submitting">159 let confirmationBox = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(6) > p:nth-child(1) > label > input[type=checkbox]"));160 confirmationBox.click();161162 //submit box163 let submitBox = await driver.findElement(By.css("#cms-content > form > p:nth-child(7) > button"));164 submitBox.click();165 166 //end and close167 await wait2s();168 driver.close();169 await wait60s();170 process.exit(1);171} ...

Full Screen

Full Screen

NoCampusRunAB.js

Source:NoCampusRunAB.js Github

copy

Full Screen

...48 //goes to website49 await driver.get(url);50 //first page (student login page)51 //gets boxes52 let usernameBox = await driver.findElement(By.name("username"));53 let pwBox = await driver.findElement(By.name("password"));54 //let submitBox = await driver.findElement(By.className("btn btn-primary"));55 //sets boxes values56 usernameBox.sendKeys(gvUsername);57 pwBox.sendKeys(gvPw,Key.ENTER);5859 await wait2s();60 url = await driver.getCurrentUrl();61 //checks what page is6263 if (url !== "https://www.gvsu.edu/hro/selfassessment-entry-edit.htm"){64 let new_assessment = await driver.findElement(By.css("#cms-content > p.selfassessment-nav > a.btn.btn-inverse"));65 new_assessment.click();66 await wait2s();67 url = await driver.getCurrentUrl();68 }6970 //for all questions below there are two objects per question with same name other than the ending71 //type Yes or No on it to select it that way7273 //actual assessment page74 //selection questions75 //tested in last thirty days (NO)76 //let testBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(2) > label > select > option:nth-child(2)"));77 //let testBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(2) > label > select > option:nth-child(3)"));78 //testBoxNo.click();79 //exposure to virus80 //let virusExposureBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(4) > label > select > option:nth-child(2)"));81 //let virusExposureBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(4) > label > select > option:nth-child(3)"));82 //virusExposureBoxNo.click();83 //be at gvsu campus today84 //let campusBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(2)"));85 //let campusBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(3)"));86 //campusBoxNo.click();87 /*88 //clinical or internship89 let internBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(2)"));90 let internBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(3)"));91 internBoxNo.click();92 //isolation93 let isolationBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(9) > label > select > option:nth-child(4)"))94 isolationBoxNo.click();95 //outside michigan96 let michBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(10) > label > select > option:nth-child(2)"));97 let michBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(10) > label > select > option:nth-child(3)"));98 michBoxNo.click();99100 //yes or no questions101 //template102 //let noseBoxYes = await driver.findElement(By.css(""));103 //let noseBoxNo = await driver.findElement(By.css(""));104 //chills105 let chillBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(13) > span > label:nth-child(1) > input[type=radio]"));106 let chillBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(13) > span > label:nth-child(2) > input[type=radio]"))107 chillBoxNo.click();108 //runny nose109 let noseBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(14) > span > label:nth-child(1) > input[type=radio]"));110 let noseBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(14) > span > label:nth-child(2) > input[type=radio]"));111 noseBoxNo.click();112 //cough113 let coughBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(15) > span > label:nth-child(1) > input[type=radio]"));114 let coughBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(15) > span > label:nth-child(2) > input[type=radio]"));115 coughBoxNo.click();116 //nausea or diarrhea117 let sickBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(16) > span > label:nth-child(1) > input[type=radio]"));118 let sickBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(16) > span > label:nth-child(2) > input[type=radio]"));119 sickBoxNo.click();120 //tired121 let tiredBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(17) > span > label:nth-child(1) > input[type=radio]"));122 let tiredBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(17) > span > label:nth-child(2) > input[type=radio]"));123 tiredBoxNo.click();124 //fever125 let feverBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(18) > span > label:nth-child(1) > input[type=radio]"));126 let feverBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(18) > span > label:nth-child(2) > input[type=radio]"));127 feverBoxNo.click();128 //loss of taste or smell129 let lossBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(19) > span > label:nth-child(1) > input[type=radio]"));130 let lossBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(19) > span > label:nth-child(2) > input[type=radio]"));131 lossBoxNo.click();132 //muscle aches133 let musBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(20) > span > label:nth-child(1) > input[type=radio]"));134 let musBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(20) > span > label:nth-child(2) > input[type=radio]"));135 musBoxNo.click();136 //breath shortness137 let breathBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(21) > span > label:nth-child(1) > input[type=radio]"));138 let breathBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(21) > span > label:nth-child(2) > input[type=radio]"));139 breathBoxNo.click();140 //sore throat141 let throatBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(22) > span > label:nth-child(1) > input[type=radio]"));142 let throatBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(22) > span > label:nth-child(2) > input[type=radio]"));143 throatBoxNo.click();144 */145146 //Agree checkbox147 let agreeCheckBox = await driver.findElement(By.css("#consentWrapper > p:nth-child(4) > label > input[type=checkbox]"));148 agreeCheckBox.click();149150 //Signiture box151 let signitureBox = await driver.findElement(By.css("#consentWrapper > p:nth-child(5) > label > input[type=text]"));152 signitureBox.sendKeys("Alyson Bixby");153154 //confirmation box155 //<input type="checkbox" name="isConfirmed" value="1" required="true" message="Please indicate you have confirmed your responses prior to submitting">156 let confirmationBox = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(6) > p:nth-child(1) > label > input[type=checkbox]"));157 confirmationBox.click();158159 //submit box160 let submitBox = await driver.findElement(By.css("#cms-content > form > p:nth-child(7) > button"));161 submitBox.click();162 163 //end and close164 await wait2s();165 driver.close();166 await wait60s();167 process.exit(1);168} ...

Full Screen

Full Screen

noCampusRunBR.js

Source:noCampusRunBR.js Github

copy

Full Screen

...48 //goes to website49 await driver.get(url);50 //first page (student login page)51 //gets boxes52 let usernameBox = await driver.findElement(By.name("username"));53 let pwBox = await driver.findElement(By.name("password"));54 //let submitBox = await driver.findElement(By.className("btn btn-primary"));55 //sets boxes values56 usernameBox.sendKeys(gvUsername);57 pwBox.sendKeys(gvPw,Key.ENTER);5859 await wait2s();60 url = await driver.getCurrentUrl();61 //checks what page is6263 if (url !== "https://www.gvsu.edu/hro/selfassessment-entry-edit.htm"){64 let new_assessment = await driver.findElement(By.css("#cms-content > p.selfassessment-nav > a.btn.btn-inverse"));65 new_assessment.click();66 await wait2s();67 url = await driver.getCurrentUrl();68 }6970 //for all questions below there are two objects per question with same name other than the ending71 //type Yes or No on it to select it that way7273 //actual assessment page74 //selection questions75 //tested in last thirty days (NO)76 //let testBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(2) > label > select > option:nth-child(2)"));77 //let testBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(2) > label > select > option:nth-child(3)"));78 //testBoxNo.click();79 //exposure to virus80 //let virusExposureBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(4) > label > select > option:nth-child(2)"));81 //let virusExposureBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(4) > label > select > option:nth-child(3)"));82 //virusExposureBoxNo.click();83 //be at gvsu campus today84 //let campusBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(2)"));85 //let campusBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(3)"));86 //campusBoxNo.click();87 /*88 //clinical or internship89 let internBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(2)"));90 let internBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(3)"));91 internBoxNo.click();92 //isolation93 let isolationBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(9) > label > select > option:nth-child(4)"))94 isolationBoxNo.click();95 //outside michigan96 let michBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(10) > label > select > option:nth-child(2)"));97 let michBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(10) > label > select > option:nth-child(3)"));98 michBoxNo.click();99100 //yes or no questions101 //template102 //let noseBoxYes = await driver.findElement(By.css(""));103 //let noseBoxNo = await driver.findElement(By.css(""));104 //chills105 let chillBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(13) > span > label:nth-child(1) > input[type=radio]"));106 let chillBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(13) > span > label:nth-child(2) > input[type=radio]"))107 chillBoxNo.click();108 //runny nose109 let noseBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(14) > span > label:nth-child(1) > input[type=radio]"));110 let noseBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(14) > span > label:nth-child(2) > input[type=radio]"));111 noseBoxNo.click();112 //cough113 let coughBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(15) > span > label:nth-child(1) > input[type=radio]"));114 let coughBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(15) > span > label:nth-child(2) > input[type=radio]"));115 coughBoxNo.click();116 //nausea or diarrhea117 let sickBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(16) > span > label:nth-child(1) > input[type=radio]"));118 let sickBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(16) > span > label:nth-child(2) > input[type=radio]"));119 sickBoxNo.click();120 //tired121 let tiredBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(17) > span > label:nth-child(1) > input[type=radio]"));122 let tiredBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(17) > span > label:nth-child(2) > input[type=radio]"));123 tiredBoxNo.click();124 //fever125 let feverBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(18) > span > label:nth-child(1) > input[type=radio]"));126 let feverBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(18) > span > label:nth-child(2) > input[type=radio]"));127 feverBoxNo.click();128 //loss of taste or smell129 let lossBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(19) > span > label:nth-child(1) > input[type=radio]"));130 let lossBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(19) > span > label:nth-child(2) > input[type=radio]"));131 lossBoxNo.click();132 //muscle aches133 let musBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(20) > span > label:nth-child(1) > input[type=radio]"));134 let musBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(20) > span > label:nth-child(2) > input[type=radio]"));135 musBoxNo.click();136 //breath shortness137 let breathBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(21) > span > label:nth-child(1) > input[type=radio]"));138 let breathBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(21) > span > label:nth-child(2) > input[type=radio]"));139 breathBoxNo.click();140 //sore throat141 let throatBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(22) > span > label:nth-child(1) > input[type=radio]"));142 let throatBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(22) > span > label:nth-child(2) > input[type=radio]"));143 throatBoxNo.click();144 */145146 //confirmation box147 let confirmationBox = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(5) > p:nth-child(1) > label > input[type=checkbox]"));148 confirmationBox.click();149150 //submit box151 let submitBox = await driver.findElement(By.css("#cms-content > form > p:nth-child(6) > button"));152 submitBox.click();153 154 //end and close155 await wait2s();156 driver.close();157 await wait60s();158 process.exit(1);159} ...

Full Screen

Full Screen

yesCampusRunTW.js

Source:yesCampusRunTW.js Github

copy

Full Screen

...41 //goes to website42 await driver.get(url);43 //first page (student login page)44 //gets boxes45 let usernameBox = await driver.findElement(By.name("username"));46 let pwBox = await driver.findElement(By.name("password"));47 //let submitBox = await driver.findElement(By.className("btn btn-primary"));48 //sets boxes values49 usernameBox.sendKeys(gvUsername);50 pwBox.sendKeys(gvPw,Key.ENTER);5152 await wait2s();53 url = await driver.getCurrentUrl();54 //checks what page is5556 if (url !== "https://www.gvsu.edu/hro/selfassessment-entry-edit.htm"){57 let new_assessment = await driver.findElement(By.css("#cms-content > p.selfassessment-nav > a.btn.btn-inverse"));58 new_assessment.click();59 await wait2s();60 url = await driver.getCurrentUrl();61 }6263 //for all questions below there are two objects per question with same name other than the ending64 //type Yes or No on it to select it that way6566 //actual assessment page67 //selection questions68 //tested in last thirty days (NO)69 //let testBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(2) > label > select > option:nth-child(2)"));70 //let testBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(2) > label > select > option:nth-child(3)"));71 //testBoxNo.click();72 //exposure to virus73 //let virusExposureBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(4) > label > select > option:nth-child(2)"));74 //let virusExposureBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(4) > label > select > option:nth-child(3)"));75 //virusExposureBoxNo.click();76 //be at gvsu campus today77 let campusBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(2)"));78 let campusBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(3)"));79 campusBoxNo.click();80 /*81 //clinical or internship82 let internBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(2)"));83 let internBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(8) > label > select > option:nth-child(3)"));84 internBoxNo.click();85 //isolation86 let isolationBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(9) > label > select > option:nth-child(4)"))87 isolationBoxNo.click();88 //outside michigan89 let michBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(10) > label > select > option:nth-child(2)"));90 let michBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(10) > label > select > option:nth-child(3)"));91 michBoxNo.click();9293 //yes or no questions94 //template95 //let noseBoxYes = await driver.findElement(By.css(""));96 //let noseBoxNo = await driver.findElement(By.css(""));97 //chills98 let chillBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(13) > span > label:nth-child(1) > input[type=radio]"));99 let chillBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(13) > span > label:nth-child(2) > input[type=radio]"))100 chillBoxNo.click();101 //runny nose102 let noseBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(14) > span > label:nth-child(1) > input[type=radio]"));103 let noseBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(14) > span > label:nth-child(2) > input[type=radio]"));104 noseBoxNo.click();105 //cough106 let coughBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(15) > span > label:nth-child(1) > input[type=radio]"));107 let coughBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(15) > span > label:nth-child(2) > input[type=radio]"));108 coughBoxNo.click();109 //nausea or diarrhea110 let sickBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(16) > span > label:nth-child(1) > input[type=radio]"));111 let sickBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(16) > span > label:nth-child(2) > input[type=radio]"));112 sickBoxNo.click();113 //tired114 let tiredBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(17) > span > label:nth-child(1) > input[type=radio]"));115 let tiredBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(17) > span > label:nth-child(2) > input[type=radio]"));116 tiredBoxNo.click();117 //fever118 let feverBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(18) > span > label:nth-child(1) > input[type=radio]"));119 let feverBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(18) > span > label:nth-child(2) > input[type=radio]"));120 feverBoxNo.click();121 //loss of taste or smell122 let lossBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(19) > span > label:nth-child(1) > input[type=radio]"));123 let lossBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(19) > span > label:nth-child(2) > input[type=radio]"));124 lossBoxNo.click();125 //muscle aches126 let musBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(20) > span > label:nth-child(1) > input[type=radio]"));127 let musBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(20) > span > label:nth-child(2) > input[type=radio]"));128 musBoxNo.click();129 //breath shortness130 let breathBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(21) > span > label:nth-child(1) > input[type=radio]"));131 let breathBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(21) > span > label:nth-child(2) > input[type=radio]"));132 breathBoxNo.click();133 //sore throat134 let throatBoxYes = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(22) > span > label:nth-child(1) > input[type=radio]"));135 let throatBoxNo = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(4) > p:nth-child(22) > span > label:nth-child(2) > input[type=radio]"));136 throatBoxNo.click();137 */138139 //confirmation box140 let confirmationBox = await driver.findElement(By.css("#cms-content > form > fieldset:nth-child(5) > p:nth-child(1) > label > input[type=checkbox]"));141 confirmationBox.click();142143 //submit box144 let submitBox = await driver.findElement(By.css("#cms-content > form > p:nth-child(6) > button"));145 submitBox.click();146147 //end and close148 await wait2s();149 driver.close();150} ...

Full Screen

Full Screen

run.js

Source:run.js Github

copy

Full Screen

...5//const driver2 = new Builder().forBrowser("firefox").build();6async function example(){7 let driver = await new Builder().forBrowser("firefox").build();8 await driver.get("http://google.com");9 await driver.findElement(By.name("q")).sendKeys("Selenium", Key.RETURN);10 //driver.quit();11}12example();13 */14const {Builder, By, Key, util} = require('selenium-webdriver');15const firefox = require("selenium-webdriver/firefox");16const chrome = require("selenium-webdriver/chrome");17const options = new firefox.Options();18const { describe, it, after, before } = require('mocha');19const chai = require('chai');20const expect = chai.expect;21const chaiAsPromised = require('chai-as-promised');22chai.use(chaiAsPromised);23const should = chai.should();24let chaiHttp = require("chai-http");25chai.should();26chai.use(chaiHttp);27process.on('unhandledRejection', () => {});28async function example(browser) {29 try {30 describe ('Pruebas funcionales con Selenium Webdriver', async function () {31 this.timeout(50000);32 let driver;33 beforeEach (async () => {34 driver = await new Builder().forBrowser(browser)35 //.usingServer("http://localhost:4444/wd/hub")36 .build();37 });38 afterEach (async () => {39 //await driver.close();40 });41/*42 it ('Prueba funcional Selenium: encontrar componente crear carpeta', async () => {43 await driver.get("https://www.google.com");44 await driver.findElement(By.name("q"));45 });46 */47 it ('Prueba funcional Selenium: crear archivo', async () => {48 await driver.get("http://localhost:8080/");49 await driver.findElement(By.id("nickname")).sendKeys("uno");50 await driver.findElement(By.id("contrasena")).sendKeys("123");51 await driver.findElement(By.id("btn_inicio_sesion")).sendKeys(Key.RETURN);52 await driver.sleep(5000);53 await driver.findElement(By.id("gestor_carpetas")).sendKeys(Key.RETURN);54 await driver.findElement(By.id("input_crearcarpeta")).sendKeys("SOG2_2");55 await driver.findElement(By.id("btn_creararchvio")).sendKeys(Key.RETURN);56 //await driver.close();57 });58 it ('Prueba funcional Selenium: crear eliminar archivo', async () => {59 await driver.get("http://localhost:8080/");60 await driver.findElement(By.id("nickname")).sendKeys("uno");61 await driver.findElement(By.id("contrasena")).sendKeys("123");62 await driver.findElement(By.id("btn_inicio_sesion")).sendKeys(Key.RETURN);63 await driver.sleep(5000);64 await driver.findElement(By.id("gestor_carpetas")).sendKeys(Key.RETURN);65 await driver.findElement(By.id("input_crearcarpeta")).sendKeys("SOG2_2");66 await driver.findElement(By.id("btn_eliminararchivo")).sendKeys(Key.RETURN);67 //await driver.close();68 });69 it ('Prueba funcional Selenium: registro de usuario', async () => {70 await driver.get("http://localhost:8080/");71 await driver.findElement(By.id("btn_redreg")).sendKeys(Key.RETURN);72 await driver.sleep(5000);73 await driver.findElement(By.id("inp_nick")).sendKeys("PruebaUser001");74 await driver.findElement(By.id("inp_correo")).sendKeys("PruebaUser001@gmail.com");75 await driver.findElement(By.id("inp_fnace")).sendKeys("01-01-2001");76 await driver.findElement(By.id("inp_pass")).sendKeys("PruebaUser001");77 await driver.findElement(By.id("inp_confpass")).sendKeys("PruebaUser001");78 await driver.findElement(By.id("btn_registro")).sendKeys(Key.RETURN);79 //await driver.close();80 });81 it ('Prueba funcional Selenium: login correcto', async () => {82 await driver.get("http://localhost:8080/");83 await driver.findElement(By.id("nickname")).sendKeys("uno");84 await driver.findElement(By.id("contrasena")).sendKeys("123");85 await driver.findElement(By.id("btn_inicio_sesion")).sendKeys(Key.RETURN);86 //await driver.close();87 });88 it ('Prueba funcional Selenium: login incorrecto', async () => {89 await driver.get("http://localhost:8080/");90 await driver.findElement(By.id("nickname")).sendKeys("uno");91 await driver.findElement(By.id("contrasena")).sendKeys("fdasfa");92 await driver.findElement(By.id("btn_inicio_sesion")).sendKeys(Key.RETURN);93 //await driver.close();94 });95 it ('Prueba funcional Selenium: crear carpeta', async () => {96 await driver.get("http://localhost:8080/");97 await driver.findElement(By.id("nickname")).sendKeys("uno");98 await driver.findElement(By.id("contrasena")).sendKeys("123");99 await driver.findElement(By.id("btn_inicio_sesion")).sendKeys(Key.RETURN);100 await driver.sleep(5000);101 await driver.findElement(By.id("gestor_carpetas")).sendKeys(Key.RETURN);102 await driver.findElement(By.id("input_crearcarpeta")).sendKeys("cnx");103 await driver.findElement(By.id("btn_crearcarpeta")).sendKeys(Key.RETURN);104 //await driver.close();105 });106 it ('Prueba funcional Selenium: eliminar carpeta', async () => {107 await driver.get("http://localhost:8080/");108 await driver.findElement(By.id("nickname")).sendKeys("uno");109 await driver.findElement(By.id("contrasena")).sendKeys("123");110 await driver.findElement(By.id("btn_inicio_sesion")).sendKeys(Key.RETURN);111 await driver.sleep(5000);112 await driver.findElement(By.id("gestor_carpetas")).sendKeys(Key.RETURN);113 await driver.findElement(By.id("input_crearcarpeta")).sendKeys("cnx");114 await driver.findElement(By.id("btn_eliminarcarpeta")).sendKeys(Key.RETURN);115 });116 it ('Prueba funcional Selenium: eliminar carpeta, buscar componente', async () => {117 await driver.get("http://localhost:8080/");118 await driver.findElement(By.id("nickname")).sendKeys("uno");119 await driver.findElement(By.id("contrasena")).sendKeys("123");120 await driver.findElement(By.id("btn_inicio_sesion")).sendKeys(Key.RETURN);121 await driver.sleep(5000);122 await driver.findElement(By.id("gestor_carpetas")).sendKeys(Key.RETURN);123 await driver.findElement(By.id("input_crearcarpeta"));124 });125 /*126 it ('find the input box and google search button', async () => {127 const result = await page.findInputAndButton();128 expect(result.inputEnabled).to.equal(true);129 expect(result.buttonText).to.include('Google');130 });131 it ('put keyword in search box and click search button', async () => {132 const result = await page.submitKeywordAndGetResult();133 expect(result.length).to.be.above(10);134 });135 */136 });137 } catch (ex) {...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...5//Sprint 16Given("Test signup functionality", { timeout: 30000 }, async function () {7 let driver = await new Builder().forBrowser("chrome").build();8 await driver.get("http://localhost:3000/signup");9 await driver.findElement(By.id("firstnamesignup")).sendKeys("test2");10 await driver.findElement(By.id("lastnamesignup")).sendKeys("test2");11 await driver.findElement(By.id("passwordsignup")).sendKeys("test2");12 await driver.findElement(By.id("emailsignup")).sendKeys("test2@gmail.com");13 await driver.findElement(By.id("addresssignup")).sendKeys("kathmandu");14 await driver.findElement(By.id("mobilesignup")).sendKeys("1234567");15 await driver.sleep(delay);16 await driver.findElement(By.id("signupBtn")).click();17 await driver.quit();18});19Given("Test login functionality", { timeout: 30000 }, async function () {20 let driver = await new Builder().forBrowser("chrome").build();21 await driver.get("http://localhost:3000/login");22 await driver.findElement(By.id("usernamelogin")).sendKeys("test2");23 await driver.findElement(By.id("passwordlogin")).sendKeys("test2");24 await driver.sleep(delay);25 await driver.findElement(By.id("loginBtn")).click();26 await driver.quit();27});28Given("Test profile functionality", { timeout: 30000 }, async function () {29 let driver = await new Builder().forBrowser("chrome").build();30 await driver.get("http://localhost:3000/profile-update");31 await driver.findElement(By.id("updateFnmae")).sendKeys("test1");32 await driver.findElement(By.id("updateLname")).sendKeys("test1");33 await driver.findElement(By.id("update-email")).sendKeys("test1@gmail.com");34 await driver.findElement(By.id("update-address")).sendKeys("test10");35 await driver.findElement(By.id("update-mobile")).sendKeys("22222222");36 await driver.findElement(By.id("update-curentpasword")).sendKeys("test1");37 await driver.sleep(delay);38 await driver.findElement(By.id("upProfileBtn")).click();39 await driver.quit();40});41//Sprint 342Given("Test AskQuestion functionality", { timeout: 30000 }, async function () {43 let driver = await new Builder().forBrowser("chrome").build();44 await driver.get("http://localhost:3000/ask-question");45 await driver.findElement(By.id("title")).sendKeys("test");46 await driver.findElement(By.id("body")).sendKeys("test");47 await driver.findElement(By.id("tag-input")).sendKeys("test");48 await driver.sleep(delay);49 await driver.findElement(By.id("submit-button")).click();50 await driver.quit();51});52Given("Test PostAnswer functionality", { timeout: 30000 }, async function () {53 let driver = await new Builder().forBrowser("chrome").build();54 await driver.get("http://localhost:3000/questions/60f6ea683770120e60944e3b");55 await driver.findElement(By.id("post-answer")).sendKeys("abcd");56 await driver.sleep(delay);57 await driver.findElement(By.id("addAnswer")).click();58 await driver.quit();59});60//Sprint 461Given("Test Comment functionality", { timeout: 30000 }, async function () {62 let driver = await new Builder().forBrowser("chrome").build();63 await driver.get("http://localhost:3000/questions/60f681de79b0dd4808c76433");64 await driver65 .findElement(By.id("exampleFormControlTextarea1"))66 .sendKeys("wwww");67 await driver.sleep(delay);68 await driver.findElement(By.id("addCommentTest")).click();69 await driver.quit();70});71//Sprint 572Given("Test subject functionality", { timeout: 30000 }, async function () {73 let driver = await new Builder().forBrowser("chrome").build();74 await driver.get("http://localhost:3000/admin/Computer");75 await driver.findElement(By.id("input-topic")).sendKeys("operating system");76 await driver.sleep(delay);77 await driver.findElement(By.id("create-button")).click();78 await driver.quit();79});80//Sprint 681Given("Test Posts functionality", { timeout: 30000 }, async function () {82 let driver = await new Builder().forBrowser("chrome").build();83 await driver.get("http://localhost:3000/tag-search");84 await driver.findElement(By.id("tag")).sendKeys("science");85 await driver.sleep(delay);86 await driver.findElement(By.id("tag-button")).click();87 await driver.quit();88});89Given("Test users functionality", { timeout: 30000 }, async function () {90 let driver = await new Builder().forBrowser("chrome").build();91 await driver.get("http://localhost:3000/user-search");92 await driver.findElement(By.id("profile-search")).sendKeys("test2");93 await driver.sleep(delay);94 await driver.findElement(By.id("button-search")).click();95 await driver.quit();96});97// Sprint 798Given("Test quiz functionality", { timeout: 30000 }, async function () {99 let driver = await new Builder().forBrowser("chrome").build();100 await driver.get(101 "http://localhost:3000/admin/quiz/Algebra/612a5a443aa9d50004b90795"102 );103 await driver.findElement(By.id("question")).sendKeys("test1");104 await driver.findElement(By.id("option1")).sendKeys("test2");105 await driver.findElement(By.id("option2")).sendKeys("test3");106 await driver.findElement(By.id("option3")).sendKeys("test4");107 await driver.findElement(By.id("option4")).sendKeys("test5");108 await driver.findElement(By.id("answer")).sendKeys("test1");109 await driver.sleep(delay);110 await driver.findElement(By.id("quiz-admin")).click();111 await driver.quit();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6 return driver.getTitle().then(function(title) {7 return title === 'webdriver - Google Search';8 });9}, 1000);10driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6 return driver.getTitle().then(function(title) {7 return title === 'webdriver - Google Search';8 });9}, 1000);10driver.quit();11var webdriver = require('selenium-webdriver');12var driver = new webdriver.Builder().forBrowser('firefox').build();13driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');14driver.findElement(webdriver.By.name('btnG')).click();15driver.wait(function() {16 return driver.getTitle().then(function(title) {17 return title === 'webdriver - Google Search';18 });19}, 1000);20driver.quit();21var webdriver = require('selenium-webdriver');22var driver = new webdriver.Builder().forBrowser('internet explorer').build();23driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');24driver.findElement(webdriver.By.name('btnG')).click();25driver.wait(function() {26 return driver.getTitle().then(function(title) {27 return title === 'webdriver - Google Search';28 });29}, 1000);30driver.quit();31var webdriver = require('selenium-webdriver');32var driver = new webdriver.Builder().for

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var By = webdriver.By;3var driver = new webdriver.Builder()4 .forBrowser('firefox')5 .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnG')).click();8driver.wait(function() {9 return driver.getTitle().then(function(title) {10 return title === 'webdriver - Google Search';11 });12}, 1000);13driver.quit();14var webdriver = require('selenium-webdriver');15var By = webdriver.By;16var driver = new webdriver.Builder()17 .forBrowser('firefox')18 .build();19driver.findElement(By.name('q')).sendKeys('webdriver');20driver.findElement(By.name('btnG')).click();21driver.wait(function() {22 return driver.getTitle().then(function(title) {23 return title === 'webdriver - Google Search';24 });25}, 1000);26driver.findElements(By.className('r')).then(function(elements) {27 console.log("Found " + elements.length + " elements");28});29driver.quit();30var webdriver = require('selenium-webdriver');31var By = webdriver.By;32var driver = new webdriver.Builder()33 .forBrowser('firefox')34 .build();35driver.findElement(By.name('q')).sendKeys('webdriver');36driver.findElement(By.name('btnG')).click();37driver.wait(function() {38 return driver.getTitle().then(function(title) {39 return title === 'webdriver - Google Search';40 });41}, 1000);42driver.findElement(By.className('r')).then(function(element) {43 console.log("Found " + element);44});45driver.quit();46var webdriver = require('selenium-webdriver');47var By = webdriver.By;48var driver = new webdriver.Builder()49 .forBrowser('firefox')50 .build();51driver.findElement(By.name('q')).sendKeys('webdriver');52driver.findElement(By.name('btnG')).click();53driver.wait(function() {54 return driver.getTitle().then(function(title) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3var searchBox = driver.findElement(webdriver.By.id('lst-ib'));4searchBox.sendKeys('Selenium');5var searchButton = driver.findElement(webdriver.By.name('btnK'));6searchButton.click();7driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.findElement(By.id("abc")).click();2driver.findElement(By.name("abc")).click();3driver.findElement(By.linkText("abc")).click();4driver.findElement(By.cssSelector("abc")).click();5driver.findElement(By.xpath("abc")).click();6driver.findElement(By.tagName("abc")).click();7driver.findElement(By.className("abc")).click();8driver.findElement(By.partialLinkText("abc")).click();9driver.findElement(By.tagName("abc")).click();10driver.findElement(By.name("abc")).click();11driver.findElement(By.linkText("abc")).click();12driver.findElement(By.cssSelector("abc")).click();13driver.findElement(By.xpath("abc")).click();

Full Screen

Using AI Code Generation

copy

Full Screen

1var element = driver.findElement(By.name('q'));2element.sendKeys('webdriver');3element.submit();4var element = driver.findElement(By.name('q'));5element.sendKeys('webdriver');6element.submit();7var element = driver.findElement(By.name('q'));8element.sendKeys('webdriver');9element.submit();10var element = driver.findElement(By.name('q'));11element.sendKeys('webdriver');12element.submit();13var element = driver.findElement(By.name('q'));14element.sendKeys('webdriver');

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3driver.findElement(webdriver.By.name('q')).sendKeys('Selenium WebDriver');4driver.findElement(webdriver.By.name('btnK')).click();5driver.quit();6var webdriver = require('selenium-webdriver');7var driver = new webdriver.Builder().forBrowser('chrome').build();8driver.findElement(webdriver.By.name('q')).sendKeys('Selenium WebDriver', webdriver.Key.ENTER);9driver.quit();10var webdriver = require('selenium-webdriver');11var driver = new webdriver.Builder().forBrowser('chrome').build();12driver.findElement(webdriver.By.name('q')).sendKeys('Selenium WebDriver');13driver.findElement(webdriver.By.name('btnK')).click();14driver.quit();15var webdriver = require('selenium-webdriver');16var driver = new webdriver.Builder().forBrowser('chrome').build();17driver.findElement(webdriver.By.name('q')).sendKeys('Selenium WebDriver', webdriver.Key.ENTER);18driver.quit();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ava automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful