function testUnifiedClickCanSubmit()
 {
     $browser = new SimpleBrowser();
     $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
     $browser->get('http://www.lastcraft.com/test/form.html');
     $this->assertTrue($browser->click('Go!'));
     $this->assertPattern('/go=\\[Go!\\]/', $browser->getContent());
 }
Example #2
0
 function testSample()
 {
     require_once 'browser.php';
     $browser = new SimpleBrowser();
     $browser->get('http://www.google.com/');
     $browser->setField('q', 'php');
     $browser->click('reporting bugs');
     $page = $browser->clickSubmitByName('btnG');
     $this->assertTrue($page);
 }
 /**
  * @param string
  * @param ???
  * @param ???
  * @return null
  */
 function __construct($root_class_name, k_ComponentCreator $components = null, k_charset_CharsetStrategy $charset_strategy = null, k_IdentityLoader $identity_loader = null, k_LanguageLoader $language_loader = null, k_TranslatorLoader $translator_loader = null)
 {
     $this->root_class_name = $root_class_name;
     $this->components = $components;
     $this->charset_strategy = $charset_strategy;
     $this->identity_loader = $identity_loader;
     $this->language_loader = $language_loader;
     $this->translator_loader = $translator_loader;
     parent::__construct();
 }
Example #4
0
 function testBack()
 {
     $browser4 = new SimpleBrowser();
     $browser4->get("http://www.google.com/");
     $browser4->get("http://www.yahoo.com/");
     $browser4->back();
     $browser4->getTitle();
     $this->assertEqual($browser4->getTitle(), 'Google');
 }
 /**
  * Fetch page from google and search for some keyword.
  */
 public function testFetchGoogleResults()
 {
     $browser = new SimpleBrowser();
     // inject debugging cookie, if we want to debug request - makes sense only if we do request to the same server with DBG module
     if (!empty($_COOKIE['DBGSESSID'])) {
         $browser->setCookie('DBGSESSID', $_COOKIE['DBGSESSID']);
     }
     $url = 'http://www.google.com/';
     $html = $browser->get($url);
     // store fetched page into temporary file and display quick download link
     TestUtils::snapshot($html, 'google-main-page');
     if ($this->assertTrue(false !== stripos($browser->getTitle(), 'google'), 'Failed loading page from ' . $url . '!')) {
         $keyword = 'simpletest';
         // load search results for "simpletest"
         $browser->setField('q', $keyword);
         $html = $browser->clickSubmitByName('btnG');
         if ($this->assertTrue(false !== strpos($browser->getTitle(), $keyword), 'Failed loading search results for ' . $keyword . '!')) {
             TestUtils::snapshot($html, 'google-search-results');
         }
     }
 }
Example #6
0
<?php

error_reporting(E_ERROR);
require 'simpletest/browser.php';
$settingsJson = file_get_contents("credentials.json");
$settings = json_decode($settingsJson, true);
$browser = new SimpleBrowser();
$browser->get('https://apply.ukba.homeoffice.gov.uk/secure/protected/account');
$browser->setField('j_username', $settings['username']);
$browser->setField('j_password', $settings['password']);
$browser->click('Log in');
$pageText = $browser->getContent();
$numWords = array('first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth');
// Set the memorable word characters
foreach ($numWords as $index => $numWord) {
    $matches = array();
    if (preg_match('/The ' . $numWord . ' character.*<input[^>]+name[=]["]([^"]+)["]/msU', $pageText, $matches)) {
        $browser->setField($matches[1], substr($settings['memorable'], $index, 1));
    }
}
$browser->click('Confirm identity');
$browser->click('Book appointment');
$browser->setField('tabbedQuestions:screens:screen0:control0:j_id184:selectOneListBox', 'T2SPSKWORK');
$browser->click('Next');
$browser->setField('tabbedQuestions:screens:screen0:control1:j_id453:selectOneRadio', 'true');
$browser->click('Next');
//$browser->setField('tabbedQuestions:screens:screen0:control1:j_id490:dateInputControl:day', '31');
//$browser->setField('tabbedQuestions:screens:screen0:control1:j_id490:dateInputControl:month', '6');
//$browser->setField('tabbedQuestions:screens:screen0:control1:j_id490:dateInputControl:year', '2012');
//$browser->setField('tabbedQuestions:screens:screen0:control2:j_id555:dateInputControl:day', '31');
//$browser->setField('tabbedQuestions:screens:screen0:control2:j_id555:dateInputControl:month', '7');
<?php

require_once "vendor/autoload.php";
require_once "config.php";
$browser = new SimpleBrowser();
$page = $browser->get('http://freshcode.club/submit/qownnotes-test');
//var_dump( $page );
var_dump($browser->getFieldByName("description"));
var_dump($browser->setFieldByName('submitter', 'pbek'));
var_dump($browser->setFieldByName("version", "1.1"));
var_dump($browser->setFieldByName("changes", "lots of changes"));
var_dump($browser->setFieldByName('req[os]', '1'));
var_dump($browser->setFieldByName('req[cc]', '1'));
$page = $browser->clickSubmit('Submit Project/Release');
var_dump($page);
            $dac = $wresto;
        }
    }
    if (substr($strVerif, 10, 1) != $dac) {
    }
}
verificaDac();
require 'scraperwiki/simple_html_dom.php';
if (!file_exists('simpletest/browser.php')) {
    //first need to download SimpleTest
    $data = file_get_contents("http://aendrew.com/sites/all/libraries/simpletest_1.1alpha3.tar.gz");
    file_put_contents("simpletest.tar.gz", $data);
    exec('tar -xzvf simpletest.tar.gz');
}
require_once 'simpletest/browser.php';
$browser = new SimpleBrowser();
$browser->useCookies();
$browser->get('https://www3.prefeitura.sp.gov.br/sf8663/formsinternet/Principal.aspx');
$viewstate = $browser->getField('__VIEWSTATE');
// $browser->setField('__VIEWSTATE', $viewstate);
$browser->setField('txtSetor', '003');
$browser->setField('txtQuadra', '006');
$browser->setField('txtLote', '0001');
$browser->setField('txtDigito', '1');
$browser->clickSubmitByName('_BtnAvancarDasii');
//$results = $browser->getField("txtNome");
$results = $browser->getContent();
$dom = new simple_html_dom();
$dom->load($results);
$arrName = array();
foreach ($dom->find('input') as $input) {
Example #9
0
 function testDeleteRequest()
 {
     $browser = new SimpleBrowser();
     $browser->delete($this->samples() . 'request_methods.php');
     $this->assertEqual($browser->getResponseCode(), 202);
     $this->assertPattern('/Your delete request was accepted/', $browser->getContent());
 }
$leveson_evidence_html = scraperwiki::scrape('http://www.levesoninquiry.org.uk/evidence/');
$leveson_evidence_html = preg_replace("#id='fs-year'#", '', $leveson_evidence_html);
$doc->loadHTML($leveson_evidence_html);
$evidence_sidebar = new DOMXPath($doc);
$xpath = "//div[@class='sidebar']/div/ul/li/a";
//arrived at via XPath Helper Chrome plugin. There may be a simpler query than this.
$hearings_links = $evidence_sidebar->query($xpath);
foreach ($hearings_links as $link) {
    //get URLs of each hearing date...
    $hearing_urls[] = 'http://www.levesoninquiry.org.uk' . $link->getAttribute('href');
}
//print_r($hearing_urls);
foreach ($hearing_urls as $url) {
    //scrape each hearing day result page for document links...
    $i = 0;
    $browser = new SimpleBrowser();
    $browser->useCookies();
    @$browser->get($url);
    $html_content = $browser->getContent();
    $hearing_page = new DOMDocument();
    $hearing_page->preserveWhiteSpace = false;
    $hearing_page->loadHTML($html_content);
    $transcript_links_list = new DOMXPath($hearing_page);
    $links_xpath = "//tr/td[2]/div/p/a";
    $evidence_links = $transcript_links_list->query($links_xpath);
    //echo $evidence_links->item(0)->nodeValue;
    $evidence_date_xpath = "/html/body[@class='page page-id-73 page-parent page-template page-template-template-evidence-php section-evidence']/div[@id='main']/div[@id='innermain evidence']/div[@id='content-box']/div[@id='primary']/table[@class='wide golden-one-two']/tr/td[1]/p";
    $evidence_date_results = $transcript_links_list->query($evidence_date_xpath);
    $evidence_date = date('Y-m-d', strtotime($evidence_date_results->item(0)->nodeValue));
    foreach ($evidence_links as $elink) {
        //scrape each document
function getPage($s, $q, $lmin, $lmax)
{
    require_once 'simpletest/browser.php';
    $browser = new SimpleBrowser();
    $browser->useCookies();
    for ($r = $lmin; $r <= $lmax; $r++) {
        $browser->get('https://www3.prefeitura.sp.gov.br/sf8663/formsinternet/Principal.aspx');
        $viewstate = $browser->getField('__VIEWSTATE');
        $setor = $s;
        $quadra = $q;
        $lote = leading_zeros(number_format($r, 0, '', ''), 4);
        //$lote = number_format($r);
        $browser->setField('txtSetor', $setor);
        $browser->setField('txtQuadra', $quadra);
        $browser->setField('txtLote', $lote);
        $browser->setField('txtDigito', verificaDac($setor, $quadra, $lote));
        $browser->clickSubmitByName('_BtnAvancarDasii');
        $results = $browser->getContent();
        $dom = new simple_html_dom();
        $dom->load($results);
        $arrName = array();
        foreach ($dom->find('input') as $input) {
            array_push($arrName, $input->name);
        }
        $arrValue = array();
        foreach ($dom->find('input') as $input) {
            array_push($arrValue, $input->value);
        }
        if (empty($arrValue)) {
        } else {
            if ($arrValue[6] == "") {
                var_dump($lote);
            } else {
                $arr = array($arrName[5] => $arrValue[5], $arrName[6] => $arrValue[6], $arrName[7] => $arrValue[7], $arrName[8] => $arrValue[8], $arrName[9] => $arrValue[9], $arrName[11] => $arrValue[11]);
                scraperwiki::save(array('txtNumIPTU'), $arr);
            }
        }
    }
}
Example #12
0
 public function __construct($conf)
 {
     $this->toupticonf = $conf;
     parent::__construct();
 }
Example #13
0
 public function testShouldAccessWebsiteURLUsingTLS11()
 {
     $browser = new SimpleBrowser();
     $browser->get('https://tls1test.salesforce.com');
     $this->assertEqual($browser->getResponseCode(), 200);
 }
 function testGet()
 {
     $browser = new SimpleBrowser();
     $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
     $this->assertTrue($browser->get($this->samples() . 'file.html'));
     $this->assertPattern('/Link to SimpleTest/', $browser->getContent());
     $this->assertEqual($browser->getTitle(), 'Link to SimpleTest');
     $this->assertFalse($browser->getResponseCode());
     $this->assertEqual($browser->getMimeType(), '');
 }
if (!file_exists('simpletest/browser.php')) {
    //first need to download SimpleTest
    $data = file_get_contents("http://aendrew.com/sites/all/libraries/simpletest_1.1alpha3.tar.gz");
    file_put_contents("simpletest.tar.gz", $data);
    exec('tar -xzvf simpletest.tar.gz');
}
if (!file_exists('phpcoord-2.3.php')) {
    //next need to download phpCoord
    $data2 = file_get_contents("http://www.jstott.me.uk/phpcoord/phpcoord-2.3.tar.gz");
    file_put_contents("phpcoord-2.3.tar.gz", $data2);
    exec('tar -xzvf phpcoord-2.3.tar.gz');
}
require_once 'simpletest/browser.php';
require_once 'phpcoord-2.3.php';
//Here we go now!
$browser = new SimpleBrowser();
$browser->useCookies();
$browser->get('http://apps.hackney.gov.uk/servapps/Northgate/PlanningExplorer/generalsearch.aspx?blah=' . rand(1, 99));
//the "blah" flag disables caching on SW.
//$viewstate = $browser->getField('__VIEWSTATE');
//$eventValidation = $browser->getField('__EVENTVALIDATION');
//$browser->setField('__VIEWSTATE', $viewstate);
//$browser->setField('__EVENTVALIDATION', $eventValidation);
$browser->setField('cboSelectDateValue', 'DATE_RECEIVED');
$browser->setField('cboMonths', '1');
$browser->setField('rbGroup', 'rbMonth');
$browser->setField('cboDays', '7');
$browser->clickSubmitByName('csbtnSearch');
$url = $browser->getUrl();
$xmlloc = 'http://apps.hackney.gov.uk' . preg_replace('/.*XMLLoc=(.*)$/', '\\1', $url);
$apps = simplexml_load_file($xmlloc);
Example #16
0
<?php

require_once '../simpletest/browser.php';
$browser = new SimpleBrowser();
$browser->get('http://mentor-stereo.codio.io:3000/app/public/index.php/login');
$browser->setFieldByName('login', 'admin');
$browser->setFieldByName('login', 'admin');
$browser->clickSubmit('Log In');