0

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?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • (1) Google and Facebook are completely different pages. Did you adjust your selectors? Does `div#registration_container` actually appear on the facebook page? (2) You're taking screenshots, do you see a page as you've expected it? (3) Please register to the [`resource.error`](http://docs.casperjs.org/en/latest/events-filters.html#resource-error) and [`casper.page.onResourceTimeout`](http://phantomjs.org/api/webpage/handler/on-resource-timeout.html) events. Maybe there are errors. – Artjom B. Jul 19 '15 at 14:48
  • 2)Making screenshots, doesn't work on facebook.com, all i get is a white page. 1)When i use selectXPath or by class it doesn't work either. – Michał Sawicki Jul 20 '15 at 07:58
  • I have added those functions catching errors and they show something like this; resource Error: errorCode: 6 errorString: SSL handshake failed url: https://facebook.com/ I found similiar themes on stackoverflow, so i'll try to to look for solution there;http://stackoverflow.com/questions/26415188/casperjs-phantomjs-doesnt-load-https-page/26419531#26419531 . Thanks. – Michał Sawicki Jul 20 '15 at 08:29
  • I find what i need, it works with adding --ssl-protocol=tlsv1 to the test command in terminal. I don't know how, so if someone could close this topic. – Michał Sawicki Jul 20 '15 at 08:44
  • I've voted to close as duplicate, you should be able to see some button to confirm the duplicate. – Artjom B. Jul 20 '15 at 09:59

0 Answers0