2015-04-28 61 views
0

是否可以将WebElement的字符串表示形式转换为WebElement将字符串转换为WebElement

因此,如果这是一个类变量:

@FindBy(css = "select[id*='budTbl:0:j_id544']") 
WebElement roleList1; 

而且有设置为roleList1

可以将字符串转换为WebElement roleList1一个字符串,以便它可以在语句中使用如

new Select(roleList1).getFirstSelectedOption().getText() 

回答

0

不可以,您不能将字符串转换为WebElement。

相反,你可以不喜欢,

if (myString.equals("roleList1")) 
    new Select(roleList1).getFirstSelectedOption().getText();