Java tutorial
package com.solidmaps.test.po; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.Select; import com.solidmaps.test.form.LicenseCivilForm; import com.solidmaps.test.form.ProductCivilCharterForm; import com.solidmaps.test.form.ProductCivilForm; public class LicenseCivilInsertPO { private RemoteWebDriver driver; public LicenseCivilInsertPO(RemoteWebDriver driver) { this.driver = driver; } public LicenseCivilListPO submit(LicenseCivilForm form) { JavascriptExecutor executor = (JavascriptExecutor) driver; new Select(driver.findElement(By.id("select-company"))).selectByValue(form.getIdCompany()); driver.findElement(By.name("numCertified")).sendKeys(form.getNumCertified()); new Select(driver.findElement(By.id("select-responsable"))).selectByValue(form.getIdUser()); driver.findElement(By.name("dateExpiration")).sendKeys(form.getDateExpiration()); driver.findElement(By.name("protocolRenovation")).sendKeys(form.getCodProtocol()); // Seleciona os Produtos for (ProductCivilForm productCivil : form.getListProducts()) { driver.findElement(By.className("ui-autocomplete-input")) .sendKeys(productCivil.getProduct().getOfficialName()); driver.findElement(By.id("produtoValorTotal")).sendKeys(productCivil.getQuantity()); new Select(driver.findElement(By.id("selectMedida"))).selectByValue(productCivil.getTypeQuantity()); WebElement addButton = driver.findElement(By.id("btnAddProduct")); executor.executeScript("arguments[0].click();", addButton); } // Seleciona os Alvars for (ProductCivilCharterForm charterType : form.getListCharters()) { new Select(driver.findElement(By.id("selectAlvara"))).selectByValue(charterType.getIdCharter()); driver.findElement(By.id("alvaraDataVencimento")).sendKeys(charterType.getDateExpiration()); WebElement addCharterButton = driver.findElement(By.id("btnAddCharter")); executor.executeScript("arguments[0].click();", addCharterButton); } WebElement submitButton = driver.findElement(By.name("btnSubmit")); executor.executeScript("arguments[0].click();", submitButton); return new LicenseCivilListPO(driver); } public String getErrorMsg() { return driver.findElement(By.id("errorMsg")).getText(); } public String getProductName(String idProduct) { return driver.findElement(By.id(idProduct)).getText(); } }