Selenium 无法调用下拉列表&;甚至不能引用当前的url

Selenium 无法调用下拉列表&;甚至不能引用当前的url,selenium,selenium-webdriver,selenium-ide,Selenium,Selenium Webdriver,Selenium Ide,这是我的代码 无法引用下拉列表,甚至无法获取url 代码包含打开url,然后单击菜单,然后打开下拉列表 我既不能打开下拉列表,也不能打开当前url,请建议 import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.seleniu

这是我的代码
无法引用下拉列表,甚至无法获取url

代码包含打开url,然后单击菜单,然后打开下拉列表 我既不能打开下拉列表,也不能打开当前url,请建议

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.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import com.gargoylesoftware.htmlunit.javascript.host.svg.SVGTextElement;

public class LoginTest { 
    private WebDriver driver;
    private String baseUrl;

    String[] arr=new String[50];

/*TO open URL*/
@BeforeMethod
public void setUp() throws Exception {
  driver = new FirefoxDriver();
  baseUrl = "http://52.74.254.186:8088/mdmapp/ShowLogin.action?popup=true";
  driver.manage().window().maximize();
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

  //UserName & Password creation
 /* for(int i=1;i<=50;i++){
      if(i<=25){
          arr[i-1]="opo."+i;
      }else{
          arr[i-1]="sooksham."+(i-25);
      }
  }*/
}

@Test (priority = 1)
public void testLoginMDM() throws Exception {
    //captures the dynamic url like popup


/*for(int i=0;i<arr.length;i++)*/{  
  driver.get(baseUrl + "/mdmapp/ShowLogin.action?popup=true");
  driver.findElement(By.id("loginId")).clear();
  driver.findElement(By.id("loginId")).sendKeys("opo.1");
  driver.findElement(By.id("loginPassword")).clear();
  driver.findElement(By.id("loginPassword")).sendKeys("opo.1");
  driver.findElement(By.id("login_")).click();
  Thread.sleep(1000);
  /*WebDriverWait wait = new WebDriverWait(driver, 10);
  WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Home")));*/

  /*Open Data Cleansing and Migration > DeDuplication & Survivorship*/
  Actions actions = new Actions(driver);
  WebElement mainMenu = driver.findElement(By.xpath("//span[contains(@class,'menu-name')]"));
  actions.moveToElement(mainMenu);  

  WebElement subMenu = driver.findElement(By.id("listpro_3"));
  actions.moveToElement(subMenu);
  actions.build().perform();
  Thread.sleep(20);

  WebElement subsubMenu = driver.findElement(By.xpath("//a[contains(text(),'DeDuplication & Survivorship')]")); 
  subsubMenu.click();

  Select dropdown = new Select(driver.findElement(By.id("ruleId")));
  dropdown.selectByVisibleText("titlecheck");
          System.out.println("The Output of the IsSelected " +
          driver.findElement(By.id("ruleId")).isSelected());
          System.out.println("The Output of the IsEnabled " +
          driver.findElement(By.id("ruleId")).isEnabled());
          System.out.println("The Output of the IsDisplayed " +
          driver.findElement(By.id("ruleId")).isDisplayed());             
             Select oSelection = new Select(driver.findElement(By.id("ruleId")));                
              oSelection.selectByVisibleText("titlecheck");               
             WebElement select = driver.findElement(By.name("ruleId"));
              Select se=new Select(select);             

se.selectByIndex(1046);

}
}



/*After method to close*/
@AfterMethod

public void closewindow()
{

    driver.quit();
}
}
import java.util.concurrent.TimeUnit;
导入org.openqa.selenium.By;
导入org.openqa.selenium.WebDriver;
导入org.openqa.selenium.WebElement;
导入org.openqa.selenium.firefox.FirefoxDriver;
导入org.openqa.selenium.interactions.Actions;
导入org.openqa.selenium.support.ui.Select;
导入org.testng.annotations.AfterMethod;
导入org.testng.annotations.BeforeMethod;
导入org.testng.annotations.Test;
导入com.gargoylesoftware.htmlunit.javascript.host.svg.SVGTextElement;
公共类登录测试{
私有网络驱动程序;
私有字符串baseUrl;
字符串[]arr=新字符串[50];
/*打开URL*/
@预处理法
public void setUp()引发异常{
驱动程序=新的FirefoxDriver();
baseUrl=”http://52.74.254.186:8088/mdmapp/ShowLogin.action?popup=true";
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
//用户名和密码创建

/*对于(inti=1;i,页面中的表单出现在iframe中

<iframe name="DeDuplication &amp; Survivorship_iFrame" src="SMDLT.action" class="tabIFrameStyle" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" width="100%" height="500px"></iframe>
注意:如果不退出iframe,您将无法访问iframe之外的其他内容

我已经测试了上面的代码,它工作得很好

希望这对您有所帮助。如果您有任何疑问,请返回

driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@name='DeDuplication & Survivorship_iFrame']")));

//then access the webelements like drop down box or text box in the page

Select dropdown = new Select(driver.findElement(By.id("ruleId")));
dropdown.selectByVisibleText("titlecheck");//etc

//After accessing all the elements in that iframe switchout of the iframe

 driver.switchTo().defaultContent();