Selenium webdriver 在selenium中找不到下拉列表

Selenium webdriver 在selenium中找不到下拉列表,selenium-webdriver,Selenium Webdriver,我有几个字段以及文本字段,日期,富文本编辑器,下拉和浏览按钮上传图像。在选择富文本编辑器后的下拉列表时,我遇到了一个错误,因为无法找到元素。这是我的密码: package newpackage; import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDri

我有几个字段以及文本字段,日期,富文本编辑器,下拉和浏览按钮上传图像。在选择富文本编辑器后的下拉列表时,我遇到了一个错误,因为无法找到元素。这是我的密码:

package newpackage;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;



public class MyClass {

    public static void main(String args[])throws NoSuchElementException,InterruptedException {
        System.setProperty("webdriver.gecko.driver", "C:\\\\geckodriver-v0.18.0-win64\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("url");

        driver.findElement(By.id("area_number")).sendKeys("1221");
        driver.findElement(By.id("street_name")).sendKeys("abc");
        driver.findElement(By.id("email_of_owner")).sendKeys("test@gmail.com");
        driver.findElement(By.id("name_of_contact")).sendKeys("Test Papri");
        driver.findElement(By.id("contact_date")).click();
        driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/button[4]")).click();


        WebDriverWait wait = new WebDriverWait(driver,20);
        wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.tagName("iframe"))));


//Code for Rich text editor goes here//

            jsExecutor.executeScript("window.scrollTo(0, document.body.scrollHeight)");
//Active value is being displayed in a li tag as selected after a button is clicked so tried with this.

           WebDriverWait wait1 = new WebDriverWait(driver,30);
          wait1.until(ExpectedConditions.elementToBeSelected(By.xpath("/html/body/section[2]/div/div[2]/div/div/div/div[2]/div[1]/form/div[7]/div[2]/div/div/div/div/ul/li[2]/a/span[1]")));
//选择下拉列表是一个按钮,因此尝试单击它。这是该按钮的xpath

           WebElement dropdown = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div/div[2]/div[1]/form/div[7]/div[2]/div/div/div/button"));
           //dropdown.click();

//driver.close();
}
}

你能给我url吗?使用这样一个绝对定位器真是个坏主意,我已经使用了所有其他定位器,但仍然存在相同的问题。我是selenium新手,如果您有任何解决方案,请提供帮助---@DemoUser123抱歉,我无法向您提供url,其机密---@Rajagopalantried with relative xpath仍然无法定位元素。。