Ejecute un caso de prueba PHPUnit Selenium 2 programáticamente ("dentro de PHP")

this is relevant question to este and i did like this https://www.youtube.com/watch?v=xB-eutXNUMXJtA&feature=youtu.be

require_once 'SeleniumTestCase/Driver.php';
$driver = new PHPUnit_Extensions_SeleniumTestCase_Driver();
$driver->setBrowser('*firefox');
$driver->setHost('localhost');
$driver->setPort(4444);
$driver->setTimeout(30000);
$driver->setBrowserUrl('http://www.google.com');
$driver->start();
$driver->open('/');

and it works fine but there is no cssselector or way to get attribute values like size (width - height) so i think using Selenium2 is better so i check

https://github.com/facebook/php-webdriver/

and i found the same issue with selecting element (note: there is select by id and class but there is no nested selector like this selector ("div.father div#child") in this example i can get father but i cant get the child for this specific father) so what can i do?

preguntado el 04 de julio de 12 a las 02:07

1 Respuestas

Once you want to do anything beyond the basic 'open a page and click a link' commands in Selenium, XPath becomes the best way of navigating around a document. For example, if you wanted to test the width of div.father div#child, algo como (no probado):

$driver->assertEquals("//div[@class='father']/div[@id='child']/@width", "500");

There are plenty of resources about on the subject. Este tutorial has a detailed run though, if you ignore where it breaks into Java at the end.

Respondido 04 Jul 12, 07:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.