Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Capybara method equivalent to findElements()

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 534
    Comment on it

    In a web-application, we may interact with every element having some unique xpath or css. The elements were easily located with its attributes but the problem arises when each element in a list have same attributes.

     

    Lets suppose we have HTML

     

    <div class="gridRowData" itemprop="description">
    <p/>
    <ol>
    <li>Develop framework with Selenium using Page Object Model technique.</li>
    <li>Exposure at all stages of Software Development Life Cycle.</li>
    <li>Implement manual test cases in Selenium.</li>
    <li>Having good knowledge of manual testing and Automation testing at all levels of STLC.</li>
    <li>Proficient in the areas of Functional, Component, Integration, User Acceptance Testing.</li>
    <li>Test mobile applications on various iOS and Android devices.</li>
    <li>Prepare test cases, test scenario, test data.</li>
    <li>Prepare test environment to run the test cases.</li>
    <li>Co-ordinate with technical development team to maintain the Process chart and timelines.</li>
    <li>Co-ordinate with product stakeholders and understand the requirements.</li>
    <li>Perform regression testing using Selenium.</li>
    <li>Experience in Test Automation, Scripts Preparation and execution within the framework</li>
    <li>Good exposure in Database testing using Selenium.</li>
    <li>Good Expertise on Exploratory Testing using Domain Knowledge</li>
    <li>Ensure delivery from development team is on time. Co-ordinate for the same.</li>
    </ol>

     

    We have to iterate through every 'li' tag and we do not have a unique attribute value for each row. So we will use .all() capybara method to iterate every row and then print every row before moving to next row.

     

    def print_each_row
      @session.all(:xpath, "//*[@class='gridRowData']/ol/li").each do |a|
        puts "Row: #{a.text}"
      end
    end

     

    This will iterate through each li and then print the text associated with each li tag. This all() method in capybara is equivalent to selenium findElements() method.

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: