Comments (16)
In my project I have a unit test to login into the application. The login page is not an angular app. This is the first test listed in the specs: [] attribute of the config file.
Here is my implementation:
var protractor = require('protractor');
require('../node_modules/protractor/jasminewd');
var config = require('../settings.js').getConfig();
describe('login', function() {
it('should login', function() {
var ptor = protractor.getInstance();
var driver = ptor.driver;
var findByName = function(name) {
return driver.findElement(protractor.By.name(name));
};
driver.get(config.url);
findByName('Email').sendKeys(config.user);
findByName('Passwd').sendKeys(config.password);
findByName('signIn').click();
});
});
from protractor.
Angular needs to be available on the page in order for Protractor to work. If Angular isn't available on the page you'll need an instance of webdriver
(see the Mocha example). Once you have an instance of webdriver
you should be able to do this:
// ptor variable is set in the before function
it('test if div appears', function() {
ptor.driver.get('/Test/Index');
ptor.driver.findElement(protractor.By.xpath('/html/body/div/div[1]/section/input')).sendKeys('whatever');
ptor.driver.findElement(protractor.By.xpath('/html/body/div/div[1]/section/input')).getAttribute('value')
.then(function(value) {
expect(value).toEqual('whatever');
});
});
from protractor.
Yup, the correct way to do this is to use the webdriver directly. It can be grabbed from a protractor instance as ptor.driver
.
from protractor.
More recently, it's available as browser.driver
, I believe:
browser.driver.findElement(by.id('username')).sendKeys('tfnico');
from protractor.
So, do you all see many users of protractor not using Angular?
from protractor.
@wayneseymour In our case, we have a non-Angular login page we need to get through before we can start testing the Angular parts.
from protractor.
@tfnico thanks for the response. Well I've been eval-ing a handful of JS libs for e2e testing and Protracotr seems solid, but we are not using angular (yet).
Do you think I should?
from protractor.
@wayneseymour I don't think this discussion belongs in a closed issue. Please ask on the Angular mailing list instead:
https://groups.google.com/d/forum/angular
from protractor.
@tfnico My apologies, you are right...and thanks. :)
from protractor.
@tfnico. Thank u very much. it worked
from protractor.
ghyjfj
from protractor.
Great solution!!
Thanks
from protractor.
Hi ,
I am new to protractor and i am trying to run few sample tests on non- angular pages, Following is the code i am trying to run on google page:
describe('cct homepage',function(){
it('should open the page with title',function()
{ browser.manage().timeouts().setScriptTimeout(60000);
browser.pause(5000);
browser.ignoreSynchronization=true;
browser.get("http://google.com",400000);
browser.sleep(2000);
element(by.id('q')).sendKeys('hi');
});
protractor is unable to locate element. Can you help me with this issue ?
from protractor.
@ProtHelp please ask a question on stackoverflow with the 'protractor' tag or post in the Gitter Channel to get help.
From the the getting help section of the README:
Please ask usage and debugging questions on StackOverflow (use the "protractor" tag) or in the Angular discussion group. (Please do not ask support questions here on Github.)
from protractor.
I am trying to use browser.driver and it throws the exception saying driver is not defined. Can someone suggest how to debug further
from protractor.
I am having the same error too, i cant find browser.driver :(
from protractor.
Related Issues (20)
- Support on Protractor after 2022 and any plans for licensed version HOT 7
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. HOT 4
- Callback function is taking long after completing the run in the protractor testcase
- [BUG] Upgrade transitive dependency "[email protected]" to fix CVE-2021-3918 HOT 1
- [BUG] input with dropdown use clear the selected tag won't remove, and click will click on the text not the element.
- Is protractor no longer working when using Angular 13? HOT 8
- protractor.Key.chord() broken in the latest chromedriver HOT 3
- Prototype Pollution in minimist
- qs version CVE-2021-44907 (High) detected in my repo dependencies
- need support for finding element under shadow root HOT 3
- Feature request - html to pdf
- Git.io deprecation notice
- Getting the ERROR "This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used." When I try to use restart() or close() method HOT 2
- Deprecated warning with Protractor HOT 2
- Interview partners for research about communication in GitHub projects wanted
- Can existing Protractor automation scripts developed in year 2020 supported on windows 2019 OS server
- webdriver Manager , chrome version higher then 114 HOT 3
- Migrate Protractor to Playwright
- Meera HOT 1
- Performance Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protractor.