juan_gandhi: (VP)
[personal profile] juan_gandhi
  override def getEOBs: Outcome = {
    import JavaScript._
    val outcome =
    for (_ ← clickElementHavingText("a", "My Stuff") onError suspiciousError;
         _ ← waitSelector("input#continue");
         _ ← clickElementHavingText("input[name=dateRangeSelection]", "past year");
         _ ← findElement("input[name=selectedMembers]");
         _ ← js(s"$foundElement.checked = true");
         _ ← clickElementHavingText("input#continue", "");
         _ ← clickElementHavingText("a", "INTERNET.com");
         _ ← findElementContainingText("*", "Processed");
         _ ← clickElementHavingText("a", "More");
         _ ← clickElementHavingText("input", "View All");
         (contents, source) <- pageContents.toResultKeepingSource) yield {
         println(contents.toFormattedString)
         jsREPL("So?")
    }
    debug(s"Got $outcome"); OK
  }


What happens here: we do these operations, monadically, since each one depends on the success of the previous one; errors are stored in negative result. If everything went well, I grab page contents and convert it to Result[Props], so the props contain all the information I managed to extract from the page.

On failure the error is logged; what can we do, it requires human interference.

All this amounts to flatMap on my Result class.
Yes, it does remind checked exception handling, but well, we are not in denial here; and we could do applicative join if needed.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 1920 21
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 26th, 2025 02:17 pm
Powered by Dreamwidth Studios