2014-03-03 114 views
3

我想編寫一個selenium IDE測試,驗證下面「style」中的bottom屬性的值。我怎樣寫一個測試這個假設:Selenium測試驗證​​樣式屬性中的css屬性

的Xpath的元素是:xpath=/html/body/div/div[3]/div[2]/div/div/div[3]/div/a 我想用verifyAttribute或相似。

我使用硒IDE:命令,目標價值...

<a href="#" class="ui-slider-handle ui-state-default ui-corner-all" style="bottom: 75%; background-color: transparent;"></a> 

回答

2

我相信這樣的事情會的工作:

COMMAND   | TARGET     | VALUE 
verifyAttribute | css=input + [email protected] | id 
+0

或者XPath的目標:// * [@ ID = 「身份識別碼」] @類 –

+0

並自定義樣式:目標:** // * [@ ID = 「身份識別碼」] @風格**價值:**底部:75%; background-color:transparent; ** –

1

我建議你不要使用Selenium IDE。看看你的xpath是否有一個簡單的鏈接,它非常複雜且難以閱讀。如果您想長期維護您的測試並獲得ROI,請自行編寫css/xpath。也可以用WebDriver代替Selenium 1.0Selenium 1.0處於維護模式。

WebDriver driver = new FirefoxDriver(); 
driver.get("http:\\your.site.com"); 
WebDriverWait wait = new WebDriverWait(driver,60); 

By findBy = By.cssSelector("a.ui-corner-all") 
WebElement element = wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(findBy)); 
String bottom_cssValue = element.getCssValue("bottom"); 
System.out.println(bottom_cssValue); 
+0

我同意你的意見。但是,我的工作現場的ISO和法規阻止我輕鬆地安裝/修改環境,因此使用Firefox插件是有道理的。我現在正在自己寫xpaths。更清潔...... –