Testng 用于dropdownlist的程序,当代码没有id或xpath时

Testng 用于dropdownlist的程序,当代码没有id或xpath时,testng,Testng,我需要在testNG中使用webdriver为dropdownlist编写程序 请参阅下面的HTML代码;它只包含一个类。如果没有id和XPath,我该如何编写dropdownlist程序 <select class="dojoxGridSelect"> <option value="Name">Name</option> <option value="Display Name">Display Name</option> <op

我需要在testNG中使用webdriver为dropdownlist编写程序

请参阅下面的HTML代码;它只包含一个类。如果没有id和XPath,我该如何编写dropdownlist程序

<select class="dojoxGridSelect">
<option value="Name">Name</option>
<option value="Display Name">Display Name</option>
<option value="Region Name">Region Name</option>
<option value="Location">Location</option>
</select>

名称
显示名称
地区名称
位置
如何在Java Selenium Webdriver中进行选择


看起来不错。只要它不应该做任何事。你想做什么?以表格形式提交?通过javascript访问它?当你做出选择时,它有什么作用吗?没有。我必须使用junit在testng中编写。@vidhyashree看起来,你对testng、junit和selenium的了解很肤浅。没有这种类型的东西可以用Junit在testng中编写。@Priyanshu是的,我不太了解selenium,但我知道的很少。我需要知道如何使用java在testng中使用类编写下拉列表。是否有其他方法不使用id、xpath。请告诉我me@vidhyashree从这里学习:
WebElement dropDown = driver.findElement(By.Xpath("//select[@class='dojoxGridSelect']"));

Select mySelect = new Select(dropDown);

mySelect.selectByVisibleText("Display Name"); //or another text from your options of select