This is my first post in StackOverFlow, and being a chinese, please ignore my poor english lol.
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.
High lighted elements are my target:
I was stucked with second xpath selector:
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
got exception enter image description here
The element is inside <frame>
, you need to switch to it first.
driver.switchTo().frame("MENU");
And to switch back
driver.switchTo().defaultContent();
You can look at the docs for more options for switchTo()
method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.