“缺少或无效'entry.level'" selenium webdriver中的错误 [英] "Missing or invalid 'entry.level'" error in selenium webdriver
本文介绍了“缺少或无效'entry.level'" selenium webdriver中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习Selenium Webdriver。我试图通过谷歌登录Quora。但在电子邮件输入部分,代码无法正常工作。我无法弄清问题是什么。请帮忙。以下是我的代码
import org.openqa。*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Demo2 {
public static void main(String [] args){
System.setProperty(webdriver.chrome.driver,C:\\chromedriver.exe );
WebDriver driver = new ChromeDriver();
String url =https://quora.com;
driver.get(url);
WebElement ele1 = driver.findElement(By.className(google_button_text));
ele1.click();
// WebElement e1 = driver.findElement((By.xpath(// * [@ id ='identifierId'])));
//e1.sendKeys(欢迎);
WebElement email1 = driver.findElement(By.name(identifier));
email1.sendKeys(fggffgfd);
WebElement next1 = driver.findElement(By.className(RveJvd snByac)); // whsOnd zHQkBf
next1.click();
WebElement password = driver.findElement(By.className(whsOnd zHQkBf));
password.click();
password.sendKeys(Sffgdffdf3);
WebElement next2 = driver.findElement(By.className(RveJvd snByac)); // whsOnd zHQkBf
next2.click();
}
}
我是什么尝试过:
import org.openqa。*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Demo2 {
public static void main(String [] args){
System.setProperty(webdriver.chrome.driver,C:\\chromedriver.exe );
WebDriver driver = new ChromeDriver();
String url =https://quora.com;
driver.get(url);
WebElement ele1 = driver.findElement(By.className(google_button_text));
ele1.click();
// WebElement e1 = driver.findElement((By.xpath(// * [@ id ='identifierId'])));
//e1.sendKeys(欢迎);
WebElement email1 = driver.findElement(By.name(identifier));
email1.sendKeys(fggffgfd);
WebElement next1 = driver.findElement(By.className(RveJvd snByac)); // whsOnd zHQkBf
next1.click();
WebElement password = driver.findElement(By.className(whsOnd zHQkBf));
password.click();
password.sendKeys(Sffgdffdf3);
WebElement next2 = driver.findElement(By.className(RveJvd snByac)); // whsOnd zHQkBf
next2.click();
}
}
解决方案
我也得到了google.com的错误相同,经过这么多努力后,我才知道输入框的id在chrome和firefox中是不同的。我正在从chrome中选择id,但是我正在执行我的chrome脚本。
所以请正确检查你的定位器问题将只在定位器中。
我通过将Chrome驱动程序更新到最新版本来解决此错误。下载最新版本并将其替换为旧版本。
以下是最新版本的链接:
下载 - ChromeDriver - 适用于Chrome的WebDriver [ ^ ]
Hi,I am learning Selenium Webdriver. I was trying to login "Quora" through Google. but in the email typing section, the code is not working. I am not able to figure out what is the problem. Please help. Below is my code
import org.openqa.*; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class Demo2 { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe"); WebDriver driver=new ChromeDriver(); String url="https://quora.com"; driver.get(url); WebElement ele1=driver.findElement(By.className("google_button_text")); ele1.click(); //WebElement e1=driver.findElement((By.xpath("//*[@id='identifierId']"))); //e1.sendKeys("Welcome"); WebElement email1=driver.findElement(By.name("identifier")); email1.sendKeys("fggffgfd"); WebElement next1=driver.findElement(By.className("RveJvd snByac")); //whsOnd zHQkBf next1.click(); WebElement password=driver.findElement(By.className("whsOnd zHQkBf")); password.click(); password.sendKeys("Sffgdffdf3"); WebElement next2=driver.findElement(By.className("RveJvd snByac")); //whsOnd zHQkBf next2.click(); } }
What I have tried:
import org.openqa.*; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class Demo2 { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe"); WebDriver driver=new ChromeDriver(); String url="https://quora.com"; driver.get(url); WebElement ele1=driver.findElement(By.className("google_button_text")); ele1.click(); //WebElement e1=driver.findElement((By.xpath("//*[@id='identifierId']"))); //e1.sendKeys("Welcome"); WebElement email1=driver.findElement(By.name("identifier")); email1.sendKeys("fggffgfd"); WebElement next1=driver.findElement(By.className("RveJvd snByac")); //whsOnd zHQkBf next1.click(); WebElement password=driver.findElement(By.className("whsOnd zHQkBf")); password.click(); password.sendKeys("Sffgdffdf3"); WebElement next2=driver.findElement(By.className("RveJvd snByac")); //whsOnd zHQkBf next2.click(); } }
解决方案
I was also getting the same error for "google.com", and after so many efforts, I came to know that the id of the input box is different in chrome and firefox. And I was picking the id from chrome but I was executing my script on chrome.
So please check your locators properly the problem will be in locators only.
I resolved this error by updating my chrome driver to the latest version. Download the latest and replace it with older version.
Here is the link to latest version:
Downloads - ChromeDriver - WebDriver for Chrome[^]
这篇关于“缺少或无效'entry.level'" selenium webdriver中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文