last day (15 days later) » 

6:38 PM
0
A: Cannot get the text of a span element using .getText() on a non-angular page

alecxeThe code you've presented, looks correct and, I suspect, there could be a timing issue. Let's use textToBePresentInElement Expected condition and wait for u4uvpzn4 text to be present inside an active tab: var EC = protractor.ExpectedConditions; var tab = element(by.css("span.active-tab-head")); ...

 
Sorry, I didn't mention that this is a non-angular page. So, would the above code work after setting browser.ignoreSynchronization = true; ?
 
@CodeRJ yes, sure.
 
due to some weird reason it fails to work! var EC = protractor.ExpectedConditions; var tab = element(by.css("span.active-tab-head")); browser.wait(EC.textToBePresentInElement(tab, 'u4uvpzn4'), 5000).then(function(){ console.log('inside browser wait'); }); tab.getText().then(function(tabFullName) { console.log('tab name is : ' + tabFullName); }); It doesn't display any of the console logs!
 
@CodeRJ interesting, please show me the complete test you have (edit the question and post there). Thanks.
@CodeRJ ah, sure, please remove the then() for browser.wait() and see if it now would fail with a timeout error, correct? That could mean the element is not getting the desired text - the active tab does not have the u4uvpzn4 text inside it.
 
same output! :(
@alexce but in html above, it shows the text is present!
 
6:39 PM
hey there
 
hey
it doesn't fail or anything.. it passes without displaying the expected output
you there @alecxe?
 
okay, yeah
so
let's solve it
first thing, could you please get rid of the page object for the testing purposes and put everything from the functions into the test itself
just to eliminate anything related to that
ok?
 
sounds good
 
also, remove the nested describe, make it just describe -> it
let's see if we would have the same output
 
gimme a sec please!
`describe('Setup', function () {
        it('test quality', function(){
            browser.ignoreSynchronization = true;
            console.log("inside spec");
            var EC = protractor.ExpectedConditions;
            var tab = element(by.css("span.active-tab-head"));

            browser.wait(EC.textToBePresentInElement(tab, 'u4uvpzn4'), 5000);
            tab.getText().then(function(tabFullName) {
                console.log('tab name is : ' + tabFullName);
            });
        });
this is what it look now!
and this is what my conf file looks like:

(function () {
    'use strict';

    exports.config = {
        // Using direct driver
        directConnect: true,
        chromeDriver: './node_modules/protractor/selenium/chromedriver',
        // Tests to run
        //
        specs: [
            './test/e2e/forms/specs/*_spec.js'
        ],
        suites: {
            webrtc: './test/e2e/forms/specs/Stats_spec.js',
        },
        // Browser setup
        //
        baseUrl: 'something',

        onPrepare: function () {
still the same output!
 
7:08 PM
okay
let's do this
instead of the last tab.getText()... line
put
expect(tab.getText()).toEqual("test");
 
same output
now that's weird!
 
7:26 PM
okay, can you put the browser.driver.get() call into the beforeEach in the test?
also, what if you would change it to browser.get()?
don't forget to set the ignoreSynchronization before the get().
 
I put browser.pause() and it was not even recognizing that.. so I reinstalled protractor and now everything works!
sorry for all the trouble
thanks a lot!
 
wow, that's weird! :)
see if it makes sense for you to answer your own question and accept it
or, accept mine, up to you
thanks!
 
I'll accept yours! you are a great help
 
thanks! Happy e2e-testing
see you on SO
 

last day (15 days later) »