Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “线程中的异常”;“主要”;org.openqa.selenium.elementNotInteractitableException:元素不可交互_Java_Selenium_Selenium Webdriver_Css Selectors_Webdriverwait - Fatal编程技术网

Java “线程中的异常”;“主要”;org.openqa.selenium.elementNotInteractitableException:元素不可交互

Java “线程中的异常”;“主要”;org.openqa.selenium.elementNotInteractitableException:元素不可交互,java,selenium,selenium-webdriver,css-selectors,webdriverwait,Java,Selenium,Selenium Webdriver,Css Selectors,Webdriverwait,我有以下代码: 导入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;

我有以下代码:

导入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.
我不明白我怎么会错。 我要说的是,我才刚刚开始。(我还在学习)。 有人可以看一看吗?

要将字符序列发送到用户名和密码字段,您需要使用
元素tobelickable()
,您可以使用以下命令:


浏览器快照:

您能否尝试使用以下更新的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();

您能编辑您的答案并删除屏幕截图吗?
  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();