簡體   English   中英

Selenium Webdriver(Java)-將類名值保存到變量中

[英]Selenium Webdriver (Java) - save classname value into the variable

我需要以某種方式存儲一個類名值-class class=\\"system Win7\\"到一個變量中。

  new WebDriverWait(Login.driver,20).until(ExpectedConditions.visibilityOfElementLocated
                    (By.xpath("//div[@class=\"system Win7\"]")))

我想在選擇具有相同類名的特定單選按鈕后使用此變量。

例如 :

1)保存類名:

String v_test =  new WebDriverWait(Login.driver,20).until(ExpectedConditions.visibilityOfElementLocated
                                (By.xpath("//div[@class=\"system Win7\"]"))).getSmth();

2)然后使用v_test查找並單擊單選按鈕

Login.driver.findElement
                (By.xpath("//div[@class="+v_test+"]")).click();

getAttribute()將為您提供您使用的屬性的值

String v_test = new WebDriverWait(Login.driver,20).until(ExpectedConditions.visibilityOfElementLocated (By.xpath("//div[@class=\"system Win7\"]"))).getAttribute("class")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM