Giter Site home page Giter Site logo

Comments (16)

andresdominguez avatar andresdominguez commented on May 5, 2024 2

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.

stickel avatar stickel commented on May 5, 2024

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.

juliemr avatar juliemr commented on May 5, 2024

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.

tfnico avatar tfnico commented on May 5, 2024

More recently, it's available as browser.driver, I believe:

browser.driver.findElement(by.id('username')).sendKeys('tfnico');

from protractor.

wayneseymour avatar wayneseymour commented on May 5, 2024

So, do you all see many users of protractor not using Angular?

from protractor.

tfnico avatar tfnico commented on May 5, 2024

@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.

wayneseymour avatar wayneseymour commented on May 5, 2024

@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.

tfnico avatar tfnico commented on May 5, 2024

@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.

wayneseymour avatar wayneseymour commented on May 5, 2024

@tfnico My apologies, you are right...and thanks. :)

from protractor.

ranadheerrannu avatar ranadheerrannu commented on May 5, 2024

@tfnico. Thank u very much. it worked

from protractor.

dgmchennai avatar dgmchennai commented on May 5, 2024

ghyjfj

from protractor.

didando8a avatar didando8a commented on May 5, 2024

Great solution!!

Thanks

from protractor.

ProtHelp avatar ProtHelp commented on May 5, 2024

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.

NickTomlin avatar NickTomlin commented on May 5, 2024

@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.

philipb4u avatar philipb4u commented on May 5, 2024

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.

VinishaDsouza avatar VinishaDsouza commented on May 5, 2024

I am having the same error too, i cant find browser.driver :(

from protractor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.