Can't find variable: page in PhantomJS

后端 未结 2 1748
暗喜
暗喜 2021-01-05 02:31

I\'m beginner in test, both in Unit Test and UI Test

I\'m trying to create a UI test for my login page using following code:

console.log(\"Teste de L         


        
2条回答
  •  鱼传尺愫
    2021-01-05 03:19

    Pretty sure that in a page.evaluate environment, you can't reference anything from the Phantom script.

    In your case, you could actually have multiple evaluate calls:

    console.log("Teste de Login");
    
    var page = require('webpage').create();
    page.open('http://localhost/login', function(status) {
        console.log("Page loadeed");
    
        if(status === "success") {
            page.render('example1.png');
        }
    
        page.evaluate(function() {
            // $("#numeroUsuario").val("99734167");
            document.getElementById('numeroUsuario').value = "99734167";
        });
    
        page.render('exampl2.png');
    
        page.evaluate(function() {
            // $("#formLogin").submit();
        });
    
        page.render('example3.png');
    
        phantom.exit();
    });
    

提交回复
热议问题