相关问题 更多 >
编程相关推荐
- 电子邮件Java mail,无法读取outlook客户端发送的“.msg附件”
- java对Spring数据的条件查询JPA在DB2(z/OS)上给出了一个417错误
- java TimerTask异常
- 从安卓应用程序向linkedIn发送带有文本的java post图像
- java无法从EditText中获取文本
- 关于重复的Java初学者
- java Hibernate未在CriteriaUpdate中调用nullvalue的用户类型
- 安卓 java。lang.IllegalStateException MediaPlayer
- java如何在多种情况下使用IgnoreCase
- java如何在使用程序时不让用户使用0?
此错误消息。。。在
…意味着xpath表达式不是有效的xpath表达式。在
当您使用双引号即
"..."
时,您需要在单引号中提供属性值,即'...'
。在所以你需要改变:
^{pr2}$收件人:
有效的代码行:
将是:
在这种情况下,不能使用发送键从下拉框中选择值:
import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; public class Testing { public static WebDriver driver; @Test public void test() throws InterruptedException { System.setProperty("webdriver.chrome.driver", "./Driver/chromedriver"); driver = new ChromeDriver(); driver.get("http://www.niftyindices.com/reports/historical-data"); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS); driver.findElement(By.xpath("//*[@id=\"HistoricalData\"]/div[1]/div/div/a")).click(); Thread.sleep(2000); List<WebElement> elements = driver.findElements(By.xpath("//*[@id=\"mCSB_2_container\"]/li")); for (WebElement element : elements) { String mCSB = element.getText(); if (mCSB.equalsIgnoreCase("NIFTY 100")) { element.click(); } System.out.println(mCSB); } } }
;