本文整理匯總了PHP中SeleniumClient\By::cssSelector方法的典型用法代碼示例。如果您正苦於以下問題:PHP By::cssSelector方法的具體用法?PHP By::cssSelector怎麽用?PHP By::cssSelector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SeleniumClient\By
的用法示例。
在下文中一共展示了By::cssSelector方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testDemo1
public function testDemo1()
{
//get url
$this->_driver->get($this->_testUrl);
//access text input
$webElement = $this->_driver->findElement(By::id("txt1"));
$webElement->clear();
$webElement->sendKeys("Text sent 1");
$this->assertEquals("Text sent 1", $webElement->getAttribute("value"));
$webElement = $this->_driver->findElement(By::id("txt2"));
$webElement->clear();
$webElement->sendKeys("Text sent 2");
$this->assertEquals("Text sent 2", $webElement->getAttribute("value"));
//access listbox
$selectElement = new SelectElement($this->_driver->findElement(By::id("sel1")));
$selectElement->selectByValue("4");
$this->assertTrue($selectElement->getElement()->findElement(By::xPath(".//option[@value = 4]"))->isSelected());
//access checkbox
$webElement = $this->_driver->findElement(By::cssSelector("html body table tbody tr td fieldset form p input#chk3"));
$webElement->click();
$this->assertTrue($webElement->isSelected());
//access radio
$webElement = $this->_driver->findElement(By::id("rd3"));
$webElement->click();
$this->assertTrue($webElement->isSelected());
//access button
$webElement = $this->_driver->findElement(By::id("btnSubmit"));
$webElement->click();
//access h2
$webElement = $this->_driver->findElement(By::cssSelector("html body h2#h2FormReceptor"));
$this->assertEquals("Form receptor", $webElement->getText());
sleep(20);
}