我有一个应用程序,在单击按钮时会打开一个包含一些元素的模式。我能够完美地访问元素。但是,当我为用户输入中的一个条件选择一个元素时,它就失败了。确保我在此处应用的if else条件存在一些问题。但是我无法找出确切的问题。
我的脚本:
String options = driver.findElement(By.cssSelector("[class^='modal hide fade in']")).getAttribute("id");
List<WebElement> element = driver.findElements(By.xpath("//*[@id="+"'"+ options +"'"+"]"+"/div[2]/div/div/div/a"));
List<String> optiontype = new ArrayList<>();
for (WebElement e : element) {
optiontype.add(e.getText());
}
System.out.println("Pick an option: 0 - Document 1 - HTML5");
Scanner k = new Scanner(System.in);
String input = optiontype.get(k.nextInt());
if (input == "Document") {
Thread.sleep(5000);
driver.findElement(By.xpath("//*[@data-type=\"Document\"]")).click();
WebElement lessonSearch = driver.findElement(By.xpath("//input[@id=\"jform_title\"]"));
lessonSearch.click();
lessonSearch.sendKeys(Constants.title);
driver.findElement(By.xpath("//button[contains(text(),'Save & Next')]")).click();
//Uploading Document
WebElement scormUpload = driver.findElement(By.id("document_upload"));
scormUpload.sendKeys(" /file/path/);
}else if(input == "HTML5") {
driver.findElement(By.xpath("//span[contains(text(), \"HTML5\")]")).click();
WebElement search = driver.findElement(By.xpath("//input[@id=\"jform_title\"]"));
search.click();
search.sendKeys(Constants.title);
driver.findElement(By.xpath("//button[contains(text(),'Save & Next')]")).click();
WebElement html5Upload = driver.findElement(By.id("tjhtmlzips_upload"));
html5Upload.sendKeys(" /file/path");
}
发生错误:
org.openqa.selenium.WebDriverException: unknown error: Element <span data-js-attr="add-lesson" data-toggle="modal">...</span> is not clickable at point (593, 612). Other element would receive the click: <div class="modal-backdrop fade in"></div>