Example #1
0
 return browserFr.visit('http://localhost:3000/fr', function () {
   var textFr, textOneCat, textTwoCats;
   textFr = browserFr.html('#text');
   textOneCat = browserFr.html('#onecat');
   textTwoCats = browserFr.html('#twocats');
   should.equal(browserFr.cookies().get('locale'), 'fr');
   should.equal(textFr, '<span id="text">Texte à tester</span>');
   should.equal(textOneCat, '<span id="onecat">1 chat</span>');
   should.equal(textTwoCats, '<span id="twocats">2 chats</span>');
   return cb();
 });
Example #2
0
 return browserEn.visit('http://localhost:3000/en?delay=1500', function () {
   var textEn, textOneCat, textTwoCats;
   textEn = browserEn.html('#text');
   textOneCat = browserEn.html('#onecat');
   textTwoCats = browserEn.html('#twocats');
   should.equal(browserEn.cookies().get('locale'), 'en');
   should.equal(textEn, '<span id="text">text to test</span>');
   should.equal(textOneCat, '<span id="onecat">1 cat</span>');
   should.equal(textTwoCats, '<span id="twocats">2 cats</span>');
   return cb();
 });
Example #3
0
	    pressButton("#ctl00_SPWebPartManager1_AccountLoginWebpartControl_ctl00_webpartAnonymousUserLogin_ctl00_buttonSubmit", function() {
	      // See if login was successful (in which case there would be a balance)
	      var balance = browser.html("#ctl00_SPWebPartManager1_AFMSCardSummaryWebpart_ctl00_wizardCardSummary_labelDisplayBalance");
	      if (!balance || typeof balance !== 'string') {
	      	res.send({status: 400, message: "Error, invalid card number"});
	      	browser.then(done, done);
	      	return;
	      }

	      var regex = /\$[0-9.]*/
	      var money = balance.match(regex)[0];

	      // Create and send the response
	      var html =
			"<html><head><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0'/> \
			<title>_money_</title></head> \
			<body style='margin:0;'><center> \
			<h1 style='font-size:25px; margin-top: 22px'>_money_</h1> \
			<p style='font-size:20px;'>_card_</p> \
			<div style='position:absolute; bottom:0; width:80%; margin:0 10%'> \
			<a style='color:purple; font-size:16px;' target='_blank' href='https://github.com/hweetty/dstools'>Source available on Github!</a> \
			<p style='font-size:14; color:gray;'>Disclaimer: Your connection to this site is not over TLS and your information is sent in the clear.</p> \
			</div> \
			</center></body></html>";
	    	html = html.replace (/_money_/g, money);
	    	html = html.replace (/_card_/g, cardNum);
	    	res.send(html);

	      browser.visit("https://www.prestocard.ca/en-US/Pages/Logout.aspx");
	      browser.then(done, done);
	    });
Example #4
0
		pressButton('login', function() {
			console.log('### titulo tag title? >> ', browser.text('title'));

			 console.log('FIN pagina2 1');
			 console.log(browser.html());
			 console.log('FIN pagina2 2');
		});
Example #5
0
			pressButton("Add Page", function() {
				assert.ok(browser.html().indexOf("testHome")!= -1);
				browser.
				select("#pageDisplayNameToDelete","testHome").
				pressButton("Delete Page", function() {
					assert.ok(browser.html().indexOf("testHome")== -1);
					callback();
				});
			});
Example #6
0
 browser.visit(url, {debug: false, runScripts: false, waitFor: 6000}, function() {
     var $ = cheerio.load(browser.html('body'), {
         normalizeWhitespace: true
     });
     numPages = $('#page-selector option').toArray().length;
     console.log('numPages: ' + numPages);
     series(function() {
         console.log('done start()')
     });
 });
Example #7
0
    browser.visit(listUrl, {debug: false, runScripts: false, waitFor: 5000}, function() {
        var $$$ = cheerio.load(browser.html('body'), {
            normalizeWhitespace: true
        });

        var listings = [];

        //get all the listings on the page
        $$$('.view-prop-details').each(function(i, n) {
            var thisTimeout = Math.random() * timeout;
            listings.push($$$(this).find('a').attr('href'));
        });


        //foreach listing, go to page and scrape it every 10 seconds.		
        getDetails(listings.shift());

        function getDetails(listingsUrl) {
            async(7, function() {
                if (listingsUrl) {                    
                    listingId = listingsUrl.substring(listingsUrl.lastIndexOf("/") + 1);
                    listingUrl = "http://www.utahrealestate.com" + listingsUrl;
                    browser.visit(listingUrl, {debug: false, runScripts: false, waitFor: 10000}, function(err) {
                        browser.wait(function() {
                            if (err) {
                                console.log("failed to load " + url);
                                console.log(err);
                            } else {
                                body = browser.html('body');
                                console.log(listingUrl);
                                scrapeDetails(body, listingId, function(err) {
                                    if (err) {
                                        error = new theError()
                                        error.error = err;
                                        error.mls = listingId;
                                        error.page = page;
                                        error.save();
                                        console.log(err);
                                        console.log("Re-scrape " + listingId);
                                    } else {
                                        console.log("DONE SCRAPING FOR " + listingId);
                                    }
                                    //browser.close();//????????? free memory ??????????
                                });
                            }
                        });
                    });
                    getDetails(listings.shift());
                } else {
                    return true;
                }
            });
        }
    });
Example #8
0
  getHtml() {
    let html = '';

    if (this.browser.document && this.browser.document.documentElement) {
      try {
        html = this.browser.html();
      } catch (error) {
        this.log(error.message, 'error');
      }
    }

    return html;
  }
Example #9
0
browser.visit("http://www.google.com/", function () {
  //透過browser.html()可以取回當下瀏覽器的內容
  console.log(browser.html());
  console.log('======================================');
  //執行form submit的動作
  browser.
    fill("q", "zombie"). //在q的輸入欄位中輸入zombie這個單字
    pressButton("搜尋", //點選"搜尋"這個按鈕,送出查詢
    function() {
      //列出查詢後的結果
      console.log(browser.html());
    })
});
Example #10
0
   browser.visit(req.query.res_uri, function() {
   //console.log(browser.location.href);
   
 //  if(browser.)
  
   if(browser.success){
       res.status(200).send(browser.html());
     
       } 
       else{
        res.status(404);
       };
       
 //  //console.log(browser.document.documentElement.innerHTML);
 //  });
 //   browser.close(); 

 //   browser.visit(req.query.res_uri)
  //        .then(function() {res.status(200).send(browser.html())});
    });
Example #11
0
 browser.wait(function() {
     if (err) {
         console.log("failed to load " + url);
         console.log(err);
     } else {
         body = browser.html('body');
         console.log(listingUrl);
         scrapeDetails(body, listingId, function(err) {
             if (err) {
                 error = new theError()
                 error.error = err;
                 error.mls = listingId;
                 error.page = page;
                 error.save();
                 console.log(err);
                 console.log("Re-scrape " + listingId);
             } else {
                 console.log("DONE SCRAPING FOR " + listingId);
             }
             //browser.close();//????????? free memory ??????????
         });
     }
 });
Example #12
0
File: index.js Project: icetee/oh
let normalize = function(){
    let html = browser.html();
    let $ = cheerio.load(html, {
        decodeEntities: false
    });
    let $datas = $('#main_content div[id^="adat"]');
    let tmp = [];

    if (first) {
        max = $('#main_content > table:nth-child(1) span.red_hl').html() - 0;
        first = !first;
    }

    $datas.each(function() {
        $(this).find('tr:nth-child(1) td:nth-child(3), tr:nth-child(2) td:nth-child(3), tr:nth-child(3) td:nth-child(3)').each(function() {
            tmp.push($(this).html());
        });
    });

    tmp = _.chunk(tmp, 3);

    for (var i = 0; i < tmp.length; i++) {
        let chunk = _.zipObject(['OM', 'name', 'address'], tmp[i]);

        institution.add(chunk);
    }

    browser.document.forms[3].submit();
    browser.wait().then((err, stat) => {
        if (institution.count() < max) {
            normalize();
        } else {
            institution.xls();
        }
    });

};
Example #13
0
      browser.visit(url, error => {
        wappalyzer.driver.document = browser.document;

        if ( !browser.resources['0'].response ) {
            return reject('No response from server');
        }

        const headers = {};

        browser.resources['0'].response.headers._headers.forEach(header => {
          headers[header[0]] = header[1];
        });

        const vars = Object.getOwnPropertyNames(browser.window);
        const html = browser.html();

        const hostname = wappalyzer.parseUrl(url).hostname;

        wappalyzer.analyze(hostname, url, {
          headers,
          html,
          env: vars
        });
      });
Example #14
0
 browser.wait(function() {
     if (err) {
         console.log("failed to load " + alistingUrl);
         console.log(err);
     } else {
         var body = browser.html('body');
         console.log(browser.location.toString());
         scrapeDetails(body, mls, function(err) {
             if (err) {
                 error = new theError()
                 error.error = err;
                 error.mls = mls;
                 error.page = page;
                 error.save();
                 console.log(err.stack);
                 console.log("Re-scrape " + mls);
                 process.exit(1);
             } else {
                 console.log("DONE SCRAPING FOR " + mls);
             }
             //browser.close();//????????? free memory ??????????
         });
     }
 });
Example #15
0
 pressButton("搜尋", //點選"搜尋"這個按鈕,送出查詢
 function() {
   //列出查詢後的結果
   console.log(browser.html());
 })
Example #16
0
	browser.visit(req.query['url'], function () {
		// Show me the document contents.
		console.log(browser.html());
		res.send(browser.html());
	});
 it('should find "Delayed Hello World!" in page after a while', function() {
     console.log("######## testing");
     console.log(browser.html());
     browser.assert.status(200);
     browser.assert.text('#response', "Delayed Hello World in 8s!");
 });
Example #18
0
 it('should see success message', function() {
   expect(browser.html('body'))
     .to.contain('Your feedback has been submitted');
 });
browser.visit("http://localhost:8100/#/app/home", function() {

	console.log(browser.html());

});
Example #20
0
 it('form does not appear', function() {
   expect(browser.html('.spaces')).to.include('You must be signed in');
 });
Example #21
0
browser.visit("http://hotel.qunar.com/city/beijing_city/dt-17849/?tag=beijing_city#fromDate=2015-07-08&toDate=2015-07-09&q=&from=qunarHotel&fromFocusList=0&filterid=a3512ff0-bcba-4e50-a8a2-d67c12c573f7_A&showMap=0&qptype=&QHFP=ZSS_A40BBE42",{userAgent:'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36'},function(){
    console.log(browser.html());
})
Example #22
0
 it('should see error message', function() {
   expect(browser.html('body')).to.contain('Name cannot be blank');
 });
Example #23
0
 it("should have the content 'Sign up'", function () {
   browser.html().should.include('Sample App');
 });
Example #24
0
				pressButton("Delete Page", function() {
					assert.ok(browser.html().indexOf("testHome")== -1);
					callback();
				});
Example #25
0
        pressButton("submitme", function() { 

            var loggedinMessage = 'I managed to login using username: '******' and password: '******' This is the content of the loggin in page '+browser.html('#main'); 

            fs.writeFile('logs/'+filename(), loggedinMessage , function (err) {
              if (err) throw err;
              console.log('Test is finished');
 
          
            });

        });