我有一個頁面,用戶可以通過點擊僅在懸停時可見的鉛筆圖標來編輯表格的標題。我在寫一個phpunit Selenium測試,並且我嘗試了'MoveToElement'和一些其他的Selenium函數來訪問這個不可見的元素,但是沒有一個被支持。如何測試懸停時可見的圖標?
當我嘗試直接訪問該元素的測試誤差和輸出
Element is not currently visible and so may not be interacted with
我怎麼能在那個圖標嘲笑一個懸停鼠標?
我有一個頁面,用戶可以通過點擊僅在懸停時可見的鉛筆圖標來編輯表格的標題。我在寫一個phpunit Selenium測試,並且我嘗試了'MoveToElement'和一些其他的Selenium函數來訪問這個不可見的元素,但是沒有一個被支持。如何測試懸停時可見的圖標?
當我嘗試直接訪問該元素的測試誤差和輸出
Element is not currently visible and so may not be interacted with
我怎麼能在那個圖標嘲笑一個懸停鼠標?
您需要移動到/ mouseover/hover /當鉛筆圖標不可見以使圖標可見時,然後在鉛筆圖標上執行操作時,無論存在哪個元素。一旦您的鉛筆圖標可見,您網站的UI如何實施將決定硒代碼的確切性。
懸停()和mouseover()不支持的PHP呢。使用moveto()時出錯並輸出錯誤 PHPUnit_Extensions_Selenium2TestCase_Exception:僅支持移動元素。請傳遞一個PHPUnit_Extensions_Selenium2TestCase_Element實例。 使用$ this-> moveto($ this-> byXPath($ pencil_xpath)) –
端具有JavaScript來做到這一點,因爲沒有其他方法,硒這樣做有PHP綁定
$script_show = 'jQuery(".class_name").css("display", "block");';
$script_hide = 'jQuery(".class_name").css("display", "none");';
//prior to accessing the non-visible element
$this->execute(array('script' => $script_show , 'args'=>array()));
//after it no longer needs to be visible
$this->execute(array('script' => $script_hide , 'args'=>array()));
我不知道,我不知道如果我知道如何如果他們實現它們...有點小菜鳥 –