[英]Java Selenium find element (xpath)
This is my first post in StackOverFlow, and being a chinese, please ignore my poor english lol. 这是我在StackOverFlow上的第一篇文章,并且是中文,请忽略我可怜的英语笑声。
I am trying to use selenium do following actions: 1.open the url(url in code) 2. click "zonal" link under the "Real-Time Market LBMP" menu, which has unique tag"P-24A" 3. get the time for "most recent interval" file and print out. 我正在尝试使用硒执行以下操作:1.打开url(代码中的url)2.单击“实时市场LBMP”菜单下的“区域”链接,该菜单具有唯一的标签“ P-24A” 3.获取时间为“最近间隔”文件并打印出来。
High lighted elements are my target: 高亮元素是我的目标:
I was stucked with second xpath selector: 我被第二个xpath选择器卡住了:
System.setProperty("webdriver.gecko.driver", "C:/Users/Haiqing/Downloads/geckodriver-v0.11.1-win64/geckodriver.exe");
WebDriver wd = new FirefoxDriver();
wd.get("http://mis.nyiso.com/public/");
wd.switchTo().frame("MENU");
WebElement zonalElement = wd.findElement(By.name("P-24Alist"));
zonalElement.click();
wd.switchTo().defaultContent();
wd.switchTo().frame("BODY");
WebElement mostRecentIntervalTime = wd.findElement(By.xpath("//a[contains(text(), 'Most recent interval')]/../following-sibling::td/span"));
System.out.println("Most recent updated time is : " + mostRecentIntervalTime.getText());
wd.quit();
And the HTML is belowed: Most recent interval 12/04/16 06:42 EST 和HTML如下:最近间隔16/04/16 06:42 EST
got exception enter image description here 出现异常,请在此处输入图片描述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.