dimanche 19 juillet 2015

My Casperjs test fails on div taken form FB page, but the same test on Google page works, why?

this is my code, it works on element(div) taken from Google page, 3 tests pass, but when i do the same on element(div) from facebook page test fails;

    Here's the code:

    var x = require('casper').selectXPath;


    casper.userAgent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");

    casper.test.begin("test", function(test) {
    // step 1: open the page.
    casper.start("https://facebook.com/", function() {
    // do an example test.
    test.assertTitle("");
    console.log("test title of the page");
    casper.capture('startingpage1.png');

    });
    casper.wait(2000, function(){
    casper.capture('startingpage2.png');

    });

    // step 2: take some screenshots.
    casper.then( function () {
    // Powinno dzialac, na google dziala
    casper.test.assertExists('div#registration_container');
    });

    casper.wait(1000, function () {

    test.assertVisible('div#registration_container', "... element is   visible.");
    this.capture("start55.png");
    });




    // actually run the steps we defined before.
    casper.run(function() {
    test.done();
    });
    });

PASS Page title is: ""
test title of the page
FAIL Find an element matching: div#registration_container
#    type: assertExists
#    file: wysiwygTest.js:23
#    code: casper.test.assertExists('div#registration_container');
#    subject: false
#    selector: "div#registration_container"
FAIL ... element is visible.
#    type: assertVisible
#    file: wysiwygTest.js:28
#    code: test.assertVisible('div#registration_container', "... element is visible.");
#    subject: false
#    selector: "div#registration_container"
FAIL 3 tests executed in 3.561s, 1 passed, 2 failed, 0 dubious, 0 skipped.

Maybe i'm missing something in my code or i didn't install and configure everything properly? Maybe there are some differences with build of these two pages, so the code works on 1 but it doesn't on second? So i would be grateful if someone explain it to me. I would be very grateful, if someone could tell me how to fix this problem.Thanks in advance, Michal Sawicki.

Aucun commentaire:

Enregistrer un commentaire