Java 在Selenium中运行的每个代码上的选定下拉列表值之间切换

Java 在Selenium中运行的每个代码上的选定下拉列表值之间切换,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我想做的是在下拉列表的两个值之间切换。每次运行代码时,我都会看到下拉值更改为另一个。为了尝试一下,请访问URL“”,并帮助我在“Jack”和“Lucy”值之间切换,您可以在给出的示例中看到这些值。我尝试的如下 WebElement orgadminselected=driver.findElement(By.xpath("//div[@class='ant-select-selection-selected-value' and text()='Lucy']")); WebEle

我想做的是在下拉列表的两个值之间切换。每次运行代码时,我都会看到下拉值更改为另一个。为了尝试一下,请访问URL“”,并帮助我在“Jack”和“Lucy”值之间切换,您可以在给出的示例中看到这些值。我尝试的如下

WebElement orgadminselected=driver.findElement(By.xpath("//div[@class='ant-select-selection-selected-value' and text()='Lucy']"));
        WebElement userselected=driver.findElement(By.xpath("//div[@class='ant-select-selection-selected-value' and text()='Jack']"));
        try {
        System.out.println(orgadminselected.getText());}catch(Exception e) {e.printStackTrace();}
        try {System.out.println(userselected.getText());}catch(Exception e){e.printStackTrace();}
        WebElement orgadmindropdown=driver.findElement(By.xpath("//div[@class='ant-select-selection-selected-value' and text()='Lucy']"));
        WebElement userdropdown=driver.findElement(By.xpath("//div[@class='ant-select-selection-selected-value' and text()='Jack']"));
        if(orgadminselected.isSelected()) {
            userdropdown.click();
            Thread.sleep(2000);
            driver.findElement(By.xpath("//div[@class='ant-select-selection__placeholder' and text()='Select Organization']")).click();
            Thread.sleep(2000);
            driver.findElement(By.xpath("//li[@class='ant-select-dropdown-menu-item' and text()='TDL Care A5']")).click();
        }
        else if(userselected.isSelected()){
            orgadmindropdown.click();
        }
但它给了我错误“org.openqa.selenium.NoSuchElementException:无法找到元素://div[@class='ant-select-selection-selected-value'和text()='Jack']。请帮忙