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 8247563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:53:18+00:00 2026-06-07T22:53:18+00:00

I need to verify whether specific slot on webpage is loaded or not. I

  • 0

I need to verify whether specific slot on webpage is loaded or not. I am using Selenium WebDriver in main() function for that (should I use a JUnit test case?).

What are ways to retrieve text between any <div> having a specific id?

If given this page:

<div id="center-2" class="promo">
    <div class="unified_widget rcmBody">
        <span class="logo"><img src="someimage.gif" /></span>
        <span class="headline">Make money by Selling items on Amazon</span>
        <span class="link"><a href="/content/sell-on-amazon.htm">Selling On Amazon</a></span>
        <span class="body">Sell your items on Amazon.com. Amazon can help you grow your business and reach more customers.</span>
        <div class="h_rule"></div>
    </div>
</div>

when <div id = center-2> is given, I need to extract

“Make money by Selling items on Amazon”,
“Selling On Amazon”,
“Sell your items on Amazon.com. Amazon can help you grow your business and reach more customers.”

Which method should I use?

  • 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-06-07T22:53:20+00:00Added an answer on June 7, 2026 at 10:53 pm

    To be sure an element is loaded, use Implicit and Explicit waits.

    Usually, when you need to interact with the element, an implicit wait is enough. Once it’s set, it’s used for every element lookup. In my experience, it’s enough for 95 % of cases.

    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    

    If you need some more advanced waiting (or just use the wait once), explicit wait is there for you.


    There are three usually used ways to retrieve an element with a specific id I know about:

    1. The preferred way:

      driver.findElement(By.id("elemId"));
      
    2. A good way if you need to begin with an element and then search its descendants:

      driver.findElement(By.cssSelector("#elemId"));
      driver.findElement(By.xpath("id('elemId')"));
      
    3. The way a lot of people uses, because they’re comfortable with XPath:

      driver.findElement(By.xpath("//*[@id='elemId']"));
      

    To know more about CSS selectors and XPath, see any tutorial on the web.


    About the text:

    String text = driver.findElement(By.id("center-2")).getText();
    System.out.println(text);
    

    outputs

    Make money by Selling items on Amazon Selling On Amazon Sell your
    items on Amazon.com. Amazon can help you grow your business and reach
    more customers.

    If you want to get the three things independently, use e.g.:

    String headline = driver.findElement(By.cssSelector("#center-2 .headline")).getText();
    System.out.println(headline);
    
    String link = driver.findElement(By.cssSelector("#center-2 .link")).getText();
    System.out.println(link);
    
    String body = driver.findElement(By.cssSelector("#center-2 .body")).getText();
    System.out.println(body);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to verify in php that a string should not start or end
i need to verify that my text box should contain only- numbers,-,/,. i have
I need a regex that will verify whether the input string is in format
In my application I need to verify whether it's signed or not. If it's
I need to verify a procedure that has an out cursor parameter. Specifically I
I need to verify that a code generated in one class is same as
I need to verify that a simplified DTD is really a subset of a
I need to verify a password using reqex. I have written one and tested
In my spec I need to verify whether strings are being converted correctly to
Need to verify that the attribute can be applied only to a class that

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.