Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.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
Selenium webdriver 在java中使用cssSelector的Selenium.findElement(By.)_Selenium Webdriver - Fatal编程技术网

Selenium webdriver 在java中使用cssSelector的Selenium.findElement(By.)

Selenium webdriver 在java中使用cssSelector的Selenium.findElement(By.),selenium-webdriver,Selenium Webdriver,上面是html。。。我在试着找到上面写着“你的邮政编码”的文字 现在我有: WebElement typeOfEntry = driver.findElement(By.cssSelector(".subscribe-modal.step-1.field-label")); System.out.println(typeOfEntry.getText()); 您应该尝试css选择器,例如: WebElement typeOfEntry = driver.findElement(By.cssSe

上面是html。。。我在试着找到上面写着“你的邮政编码”的文字

现在我有:

WebElement typeOfEntry = driver.findElement(By.cssSelector(".subscribe-modal.step-1.field-label"));
System.out.println(typeOfEntry.getText());

您应该尝试css选择器,例如:

WebElement typeOfEntry = driver.findElement(By.cssSelector("#js-zip-modal-step label"));
System.out.println(typeOfEntry.getText());

这可能对您有用

您尝试过xpath吗?