Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonathan Grieve
Treehouse Moderator 91,253 PointsSelenium runs tests then automatically closes the browser
Hi all,
Here's a problem.
I've got my finished code which successfully runs the tests, but then promptly closes the browser. I don't think it's a problem with code, maybe I need to update Selenium Web Driver?
[0926/152756.483:ERROR:process_reader_win.cc(123)] NtOpenThread: {Access Denied} A process has requested access to an object, but has not been granted those access rights. (0xc0000022)
[0926/152756.552:ERROR:exception_snapshot_win.cc(87)] thread ID 7616 not found in process
[0926/152756.552:WARNING:crash_report_exception_handler.cc(62)] ProcessSnapshotWin::Initialize failed
//import seleniun package
const selenium = require("selenium-webdriver");
//require browser driver for google Chrome
require("chromedriver");
//use Selenium By Library
const By = selenium.By;
const HomePage = require("./pages/home");
//build pattern to access webpage.
const driver = new selenium.Builder()
.forBrowser("chrome")
.build();
const homePage = new HomePage(driver);
homePage.open();
//array of invitees
const invitees = [
'Gonzalo Torres del Fierro',
'Shadd Anderson',
'George Aparece',
'Shadab Khan',
'Joseph Michael Casey',
'Jennifer Nordell',
'Faisal Albinali',
'Taron Foxworth',
'David Riesz',
'Maicej Torbus',
'Martin Luckett',
'Joel Bardsley',
'Reuben Varzea',
'Ken Alger',
'Amrit Pandey',
'Rafal Rudzinski',
'Brian Lynch',
'Lupe Camacho',
'Luke Fiji',
'Sean Christensen',
'Philip Graf',
'Mike Norman',
'Michael Hulet',
'Brent Suggs'
];
//perform actions
//addInvitee("first name");
//addInvitee("last name");
//invitees.forEach(invitee => homePage.addInvitee(invitee));
invitees.forEach(homePage.addInvitee, homePage);
//call the functions
homePage.removeInvitee("Shadd Anderson");
homePage.toggleNonRespondersVisibility();
const By = require("selenium-webdriver").By;
class HomePage {
constructor(driver) {
//store reference to the driver in instance
this.driver = driver;
//JavaScript Object Literal
this.locators = {
inviteeForm: By.id("registrar"),
inviteeNameField: By.name("name"),
toggleNonRespondersVisibility: By.css(".main > div input"),
removeButtonForInvitee: invitee => By.xpath(`//span[text() = "${invitee}"]/../button[last()]`)
};
}
open() {
//open URL
this.driver.get(process.env.URL);
}
//keep it DRY with functions
addInvitee(name) {
this.driver.findElement(this.locators.inviteeNameField)
.sendKeys(name);
this.driver.findElement(this.locators.inviteeForm).submit();
}
removeInvitee(invitee) {
this.driver.findElement(this.locators.removeButtonForInvitee(invitee))
.click();
}
toggleNonRespondersVisibility() {
this.driver.findElement(this.locators.toggleNonRespondersVisibility)
.click();
}
}
module.exports = HomePage;
Jonathan Grieve
Treehouse Moderator 91,253 PointsI did just test this on my laptop, having done a git pull on the project.
The test seems to have run properly and not crashed the browser. I've verified also that it did not add anything new to the npm.debug
file.
I must have done something to the configuration on my PC that changed something but I can't think what. I know you're not all mind readers but any thoughts? Help :)??
1 Answer
linda wu
3,016 PointsHave you installed with protractor? I have seen the similar error message posted on https://stackoverflow.com/questions/40246655/chrome-automation-extension-error-using-selenium-with-protractor-jasmine
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Linda, Iβm sorry I seemed to have missed this answer. But Iβll make a point To try it out, I donβt think the course used it but it canβt hurt to try :)
Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 Pointsanyone? :-)