【发布时间】:2016-02-25 11:18:38
【问题描述】:
有人知道如何验证字符串列表是按字母顺序排列还是不使用java。我尝试使用 compareTo(),但没有得到它。
* **仅用于String的验证。如果是打印“列表按字母顺序排列”和 不,打印“Not in order”
这里是代码:::
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class ValidationOfSelectDropDown_4 {
public static void main(String[] args) throws InterruptedException {
WebDriver driver=new FirefoxDriver();
driver.get("http://my.naukri.com/manager/createacc2.php?othersrcp=16201&err=1");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().maximize();
WebElement single=driver.findElement(By.xpath("//select[@id='ugcourse']"));
Select dd=new Select(single);
String str=single.getText();
System.out.println(str);
}}
字符串str的O/p为:
选择
不追求毕业
文学学士
B.Arch
BCA
B.B.A
...直到选项结束
【问题讨论】:
-
您可以让问题更简单:如果您已经知道如何从 webdriver 获取字符串列表,那么问题是“是按顺序排列的字符串列表”,而 webdriver 部分无关紧要。