require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class CategoryModifTest extends PHPUnit_Extensions_SeleniumTestCase
{
protected function setUp()
{
$this->setBrowser("*firefox");
$this->setBrowserUrl("http://...");
}
public function testCategoryModif()
{
$this->open("http://...");
$this->type("modlgn_username", "admin");
$this->type("modlgn_passwd", "password");
$this->click("link=Connexion");
$this->waitForPageToLoad("30000");
$this->open("http:.../administrator/index.php?...");
$this->waitForPageToLoad("30000");
$name = $this->getTable("//div[@id='element-box']/div[2]/form/table.2.2");
$this->click("link=".$name);
$this->waitForPageToLoad("30000");
$this->type("name", "Ordinateurs portables modifié");
$this->click("//td[@id='toolbar-save']/a/span");
$this->waitForPageToLoad("30000");
try {
$this->assertTrue($this->isTextPresent("Ordinateurs portables modifié"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
$this->click("link=Ordinateurs portables modifié");
$this->waitForPageToLoad("30000");
$this->type("name", "Ordinateurs portables");
$this->click("//td[@id='toolbar-save']/a/span");
$this->waitForPageToLoad("30000");
$this->click("link=Déconnexion");
$this->waitForPageToLoad("30000");
}
}
// On déclare le packet selenium_webdriver.
use selenium_webdriver::*;
// Le point de départ
fn main() {
// Cela permet de créer un pilote de navigateur et le navigateur indiqué est Chrome.
let mut driver = Browser::start_session(BrowserName::Chrome, "--disable-popup-blocking", "--disable-extensions");
// Le pilote va se charger d'ouvrir une nouvelle page.
driver.open("https://www.wikipedia.org/").unwrap();
// Cela permet de rechercher la barre de recherche.
let search = driver.find_element(LocatorStrategy::CSS("#searchInput" as &'static str)).unwrap();
// Cela permet de taper 'Selenium (informatique)' dans la barre de recherche.
let _ = search.send_keys(&"Selenium (informatique)");
// Le pilote va chercher le bouton
let btn = driver.find_element(LocatorStrategy::CSS("input[type=submit]" as &'static str)).unwrap();
// Et il va cliquer !
btn.click();
}
# Créer une session Chrome
driver = webdriver.Chrome()
driver.implicitly_wait(30)
driver.maximize_window()
# Appeler l’application web
driver.get("http://www.wikipedia.org")
driver.implicitly_wait(30)
# Localiser la zone de texte
search_field = driver.find_element(By.CSS_SELECTOR, "#searchInput")
search_field.clear()
driver.implicitly_wait(30)
# Saisir et confirmer la recherche
search_field.send_keys("Selenium (informatique)")
search_field.submit()
driver.implicitly_wait(30)
#Renvoie le titre de la page et son lien
print('Le titre de la page est {0}, et le lien est {1}'.format(driver.title, driver.current_url))
# Fermer la fenêtre du navigateur
driver.quit()
// Utilisation de la librairie npm selenium-webdriver
const {Builder, By} = require('selenium-webdriver');
// Instanciation du web driver qui va piloter Firefox (geckodriver)
const driver = new Builder().forBrowser('firefox').build();
// Charge la page
driver.get('https://www.wikipedia.org/');
// Recherche l'élément dans la page pour saisir la recherche
driver.findElement(By.id('searchInput')).then(searchInput => {
// Saisie de la recherche
searchInput.sendKeys('Selenium (informatique)');
// Recherche le bouton dans la page pour envoyer la recherche
driver.findElement(By.css('button[type="submit"]')).then(submitBtn => {
// Envoi de la recherche
submitBtn.click();
});
});