SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Dec 2011
    Posts
    129
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    HtmlUnitDriver Usage in Selenium WebDRiver

    Hi All,

    Can anyone please help me the usage of HtmlunitDriver?

    I tried in Google, I am bit new to Selenium So i am unable to understand the examples provided in Google?

    Is it open any browser? where exactly we will use this one?

    Is there any extra configuration required to use this driver?


    Thanks in Advance,
    Chowdary.

  2. #2
    SQA Knight
    Join Date
    May 2006
    Location
    Playa Del Rey, California, United States
    Posts
    2,594
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0
    HTMLUnit is a headless browser. But these days more people will generally opt to use the PhantomJS driver instead because it more closely mimics Chrome while HTMLUnit does not render close to any production browsers out there.

    What HTMLUnit browser is good for is if you're a framework developer that wants his unit tests to run quickly for testing extensions you're writing for Selenium. HTML unit is a good way to go since it doesn't incur extra dependencies of deploying PhantomJS on the host machine when running it CI on a open source cloud environment.
    David Lai
    SDET / Consultant
    LinkedIn profile

  3. #3
    Member
    Join Date
    Dec 2011
    Posts
    129
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0
    Thanks dlai,

    Still confusion is going on, how Selenium will interact with this browser if there is no UI for the application?
    i tried below piece of code but it fails at identifying the locator

    WebDriver driver = new HtmlUnitDriver();
    driver.get("https://www.google.co.in");
    driver.findElement(By.id("gbqfq")).sendKeys("Chowd ary");


    Regards,
    Chowdary

  4. #4
    SQA Knight
    Join Date
    May 2006
    Location
    Playa Del Rey, California, United States
    Posts
    2,594
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0
    Quote Originally Posted by Chowdary287 View Post
    Thanks dlai,

    Still confusion is going on, how Selenium will interact with this browser if there is no UI for the application?
    i tried below piece of code but it fails at identifying the locator

    WebDriver driver = new HtmlUnitDriver();
    driver.get("https://www.google.co.in");
    driver.findElement(By.id("gbqfq")).sendKeys("Chowd ary");


    Regards,
    Chowdary

    As I mentioned, HtmlUnit is not recommended for doing any sort of testing beyond unit testing selenium itself or frameworks for selenium. It lacks a layout and a proper javascript engine that'll allow it to run any sort of complicated page correctly. It's mainly there for the benefit of developers writing modules for selenium to unit test them.

    Use something like https://github.com/detro/ghostdriver instead for headless testing.

    There is a lot of bad examples out there that use htmlUnit driver mainly because it requires not environment setup so anyone can run those examples without installing any browsers or browser drivers. As for how headless browsers work, it's basically imagine if you had a real browser running, but the graphics were turned off. so from a user's point of view, it's just a command line prompt, but from the code's perspective, there's code that's reading the HTML and JavaScript and performing the actions on those elements, and keeping track of those element states.
    David Lai
    SDET / Consultant
    LinkedIn profile

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 06:07 AM.

Copyright BetaSoft Inc.