¿Puede alguien ayudarme por favor?Resalte elementos en WebDriver durante el tiempo de ejecución
¿Cómo puedo resaltar todos los elementos web en la siguiente clase durante la ejecución de la prueba en WebDriver? Con Selenium RC, fue bastante sencillo pero con WebDriver estoy luchando.
Le agradecería a alguien que por favor me proporcione algún código que yo pueda probar, también donde encajaría ese código en la siguiente clase - lo siento, mis habilidades Java no son tan buenas.
package hisScripts;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.*;
import org.testng.Assert;
import static org.testng.Assert.fail;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Actions;
public class R_LHAS_Only_Account_Verification extends HIS_Login_Logout{
public WebDriver driver;
public String baseUrl;
public int exeMonth;
private StringBuffer verificationErrors = new StringBuffer();
@BeforeClass
@Parameters ({"browser1", "url", "executionMonth"})
public void setUp(String browser1, String url, int executionMonth) throws Exception {
exeMonth = executionMonth;
baseUrl = url;
if (browser1.equals("FF")) {
driver = new FirefoxDriver();
} else if (browser1.equals("IE")){
driver = new InternetExplorerDriver();
}
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void R_LHAS_Reports() throws Exception {
R_LHAS_Only_Login(baseUrl, driver);
Assert.assertEquals("Kingston upon Thames (RB)", driver.findElement(By.xpath("//html/body/div[9]/div/div[3]/div/div/div")).getText());
Assert.assertEquals("Average price", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr/td")).getText());
Assert.assertEquals("% price change", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[2]/td")).getText());
Assert.assertEquals("Lower quartile price", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[3]/td")).getText());
Assert.assertEquals("Time to sell (weeks)", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[4]/td")).getText());
Assert.assertEquals("% asking price achieved", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[5]/td")).getText());
Assert.assertEquals("House price to earnings ratio", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[6]/td")).getText());
Assert.assertEquals("Cost of buying outright - LQ 2 bed £pw", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[7]/td")).getText());
Assert.assertEquals("Private rent 2 bed £pw", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[8]/td")).getText());
Assert.assertEquals("80% private rent 2 bed £pw", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[9]/td")).getText());
Assert.assertEquals("Social rent 2 bed £pw", driver.findElement(By.xpath("//table[@id='tableId']/tbody/tr[10]/td")).getText());
R_LHAS_Only_Logout(baseUrl,driver);
}
@AfterClass(alwaysRun=true)
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (! "".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
}
No es un problema en absoluto. Cuando dices resaltar un elemento, ¿quieres imitar al usuario que mantiene presionado el mouse y realmente resaltar ese elemento? – AndyPerfect
Básicamente cuando se ejecutan las pruebas, quiero poder ver los elementos que se verifican, afirman, etc. En palabras simples, estoy buscando un controlador de web equivalente para esto: selenium.getEval ("selenium.browserbot.setShouldHighlightElement (true)") ; Esto es de Selenium RC pero estoy migrando mis scripts de prueba a webdriver. – user929258