Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6893757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:41:54+00:00 2026-05-27T06:41:54+00:00

If I call findEventWithStatus(Comment,Completed) instead of returning a single event it returns the entire

  • 0

If I call findEventWithStatus(“Comment”,”Completed”) instead of returning a single event it returns the entire list of events generated by the getEvents() method. Why is this so? Applicable code is below.

Definition of the Event object:-

class Event {
    String description
    String date
    String status
    WebElement editEvent
    WebElement deleteEvent
}

Get the events from the HTML table using selenium:-

def getEvents() {
    def eventSize = driver.findElements(By.xpath('//div[@id[contains(.,"eventsReviewTable")]]/table/tbody/tr')).size()
    def eventList = new ArrayList()
    def event = new Event()
    def x
    for (y in 0..eventSize-1) {
        x = (y+1).toString()
        event.date = driver.findElement(By.xpath("//div[@id[contains(.,'eventsReviewTable')]]/table/tbody/tr["+ x + "]/td[1]/div/span")).getText()
        event.description = driver.findElement(By.xpath("//div[@id[contains(.,'eventsReviewTable')]]/table/tbody/tr["+ x + "]/td[2]/div/span")).getText()
        event.status = driver.findElement(By.xpath("//div[@id[contains(.,'eventsReviewTable')]]/table/tbody/tr["+ x + "]/td[4]/div/span")).getText()
        event.editEvent =  driver.findElement(By.xpath("//div[@id[contains(.,'eventsReviewTable')]]/table/tbody/tr["+ x + "]/td[6]/div/a[@id[contains(.,'editEventLink')]]"))
        event.deleteEvent =  driver.findElement(By.xpath("//div[@id[contains(.,'eventsReviewTable')]]/table/tbody/tr["+ x + "]/td[6]/div/a[@id[contains(.,'deleteEventLink')]]"))
        eventList.add(event)
        event = new Event()
    }
    return eventList
}

Finding an event with a specific status and description:-

def findEventWithStatus(String desc, String status) {
    def events = getEvents()
    events.each() {
        if(it.description == desc && it.status == status) {
             return it
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:41:55+00:00Added an answer on May 27, 2026 at 6:41 am

    The problem is that the return it from the findEventWithStatus method is returning from the closure passed to event.each instead of returning from the findEventWithStatus method. So, the each method is not doing anything really, and as each returns the collection in which it was invoked, it is returning the events value, which is what is finally being returned from findEventWithStatus as the events.each { ... } is the last statement in that method. I hope that wasn’t too confusing hehe.

    Anyway, it can be fixed using a for statement instead of each, but, as you are searching for an object, the find method will work much better:

    def findEventWithStatus(String desc, String status) {
        getEvents().find { it.description == desc && it.status == status }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I call an action method with a jquery post : $('#selector').click(function (event) { var
I call the following function with a mouseover event but it's not working. My
I call addNotify() method in class that I posted here. The problem is, that
I call: [[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ] on the applicationDidFinishLaunching event.. I
I call an ajax enabled wcf service method , <script type=text/javascript> function GetEmployee() {
Call like: mAsyncRunner.request(me, params,new AsyncFacebookRunner.RequestListener() returns me all info for user /according to permisions/.
Cannot call action method 'System.Web.Mvc.PartialViewResult FooT' on controller 'Controller' because the action method is
Call me crazy... Hey i wanna know that how you people comment or ask
Call for quick method is: QuickMethods.IsFullyEmpty(CompanyName.Text) || QuickMethods.IsFullyEmpty(UsernameText.Text) || QuickMethods.IsFullyEmpty(PasswordText.Password) and implementation is: public
I call getHeight and getWidth in a custom view in the onDraw() method. getHeight()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.