0

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:

enter image description here

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

2
  • Create a minimal example and update your question (image description, remove bold)... Commented Dec 4, 2016 at 12:18
  • 1
    Thanks Jeroen, I updated my question and now looks cleaner... Commented Dec 4, 2016 at 12:50

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Comments are not for extended discussion; this conversation has been moved to chat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.