我有以下代码:
导入java.util.HashMap; 导入java.util.Map;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
public class LoginToThePortal {
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.chrome.driver","C:\\chromedriver\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window();
driver.get("");
Thread.sleep(2000);
WebElement username=driver.findElement(By.id("sfdc_username_container"));
Thread.sleep(5000);
WebElement password=driver.findElement(By.id("sfdc_password_container"));
WebElement login=driver.findElement(By.xpath("//*[@id=\"centerPanel\"]/div/div[2]/div/div[2]/div/div[3]/button/span"));
username.sendKeys("");
password.sendKeys("");
login.click();
}
}
我收到以下错误:
Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: element not interactable.
我不明白我怎么错了。 我会提到我正处于开始阶段。 (我还在学习)。 有人可以看一下吗?
最佳答案
您可以尝试使用以下更新的 xpath,希望这能解决您的问题
System.setProperty("webdriver.chrome.driver","C:\\chromedriver\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window();
driver.get("https://qa-advisor.cs105.force.com/s/login/");
Thread.sleep(2000);
WebElement username = driver.findElement(By.xpath
("//div[@id='sfdc_username_container']//child::div/input[1]"));
Thread.sleep(5000);
WebElement password = driver.findElement(By.xpath
("//div[@id='sfdc_password_container']//child::div/input[1]"));
WebElement login = driver.findElement(By.xpath
("//button[@class='slds-button slds-button--brand loginButton uiButton-
-none uiButton']//child::span"));
username.sendKeys("test");
password.sendKeys("test");
login.click();
关于java - 线程 "main"org.openqa.selenium.ElementNotInteractableException : element not interactable 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65035457/