我有一些onclick
屬性的按鈕,有些則沒有。我想檢查指定的元素是否具有onclick
屬性。我怎樣才能做到這一點?Selenium RC:如何檢查一個元素是否有給定的屬性?
getAttribute()
返回屬性值,當它有一個。當它沒有時,它會拋出一個RuntimeException並停止測試(即使我將它包裝在try/catch塊中)。
$onclickValue = $this->getAttribute("[email protected]"); //works when the attribute exists
謝謝你的評論。我一直在爲Selenium IDE尋找這個例子,而不是RC,因此它有所幫助。 – 2012-10-25 15:53:49