Selenium Beginner Tutorial 13 - How to use HtmlUnit Driver

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

Комментарии • 92

  • @bilalrahaoui191
    @bilalrahaoui191 5 лет назад +8

    Don't forget to add htmlunit driver jar to build path :)

  • @yogs3870
    @yogs3870 6 лет назад +3

    Thanks a lot bro. Please keep sharing more videos. Your approach is very practical

  • @bilalrahaoui191
    @bilalrahaoui191 5 лет назад

    i didn't get what HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME); should do ?
    because I see the same result with this HtmlUnitDriver driver = new HtmlUnitDriver();

    • @RaghavPal
      @RaghavPal  5 лет назад +1

      Using the above will emulate chrome browser

  • @ChandraShekar-nu8yq
    @ChandraShekar-nu8yq 5 лет назад

    Hi Raghav, I am getting below error.
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    HtmlUnitDriver cannot be resolved to a type
    Can you please help me ?

    • @RaghavPal
      @RaghavPal  5 лет назад

      Hi Chandra, I believe HtmlUnitDriver is no longer used. You can skip this

    • @ChandraShekar-nu8yq
      @ChandraShekar-nu8yq 5 лет назад

      Hi Raghav,
      Do you mean to say that i can skip chapter 13 and can continue with next ?

    • @RaghavPal
      @RaghavPal  5 лет назад +1

      Yes you can, Just for information for headless testing, we can now use Chrome headless and Firefox headless. These browsers have in-built headless mode, You will find more information online on this.

  • @smanap3859
    @smanap3859 7 лет назад +1

    Raghav, Will you post some information on JUnit, TestNG and maven integration for CI etc?.. Thank you for all the videos in selenium.. I am yet to check Jmeter videos, which I will be doing now. Thanks again

    • @RaghavPal
      @RaghavPal  7 лет назад

      I will do that soon Smana. You can see other playlists here - ruclips.net/channel/UCTt7pyY-o0eltq14glaG5dgplaylists

  • @knownothing1277
    @knownothing1277 7 лет назад +1

    I have added all the jar files in the project on eclipse but still can't get to import org.openqa.selenium.htmlunit.HtmlUnitDriver. Please advise.

    • @RaghavPal
      @RaghavPal  7 лет назад

      Alok, have you added the jars to build path as described in earlier videos. If you still face issues, send me the logs for troubleshooting.

    • @knownothing1277
      @knownothing1277 7 лет назад

      Thanks for your reply. Yes, I have added the jar files through the build path but I am not sure where I am wrong. Anyway, please see the screenshot in my email.

    • @RaghavPal
      @RaghavPal  7 лет назад +2

      Alok, the issue is you are using selenium jar 2.53 ver.
      The root cause here is : HtmlUnitDriver was part of standard Selenium library until ver 2.52.
      After this it got dropped and was added as a separate jar.
      Solution : You can either download separate HtmlUnit Driver jar from here:
      mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-htmlunit-driver
      OR
      You can downgrade your selenium jar to 2.52 or earlier version.
      Hope this helps.

    • @knownothing1277
      @knownothing1277 7 лет назад +1

      Hi Raghav, You are so nice and great! All set now and it works perfectly. I am so happy with your great support and solutions. Thank you.

    • @RaghavPal
      @RaghavPal  7 лет назад

      Keep Learning :)

  • @archanadeshmukh6632
    @archanadeshmukh6632 5 лет назад

    I am unable to import the HtmlUnitDriver driver so can't run it. That option is not available for me

    • @RaghavPal
      @RaghavPal  5 лет назад +1

      Hi Archana, HtmlUnitDriver is not very much used these days. You can check with Chrome headless or firefox headless browsers. There are videos in this playlsit - ruclips.net/p/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa

  • @vishsah9724
    @vishsah9724 4 года назад

    Hi Raghav,
    i am getting this error
    Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices

    • @RaghavPal
      @RaghavPal  4 года назад +2

      Hi Vish, HTML Unit Driver may not be stable. These days we use Chrome and Firefox headless browser. Both these browsers have in-built headless mode. You can skip this session if facing issues.

  • @m.pavankumarreddy7399
    @m.pavankumarreddy7399 2 года назад

    Hi raghav do we need to add htmlunitdriver dependency in pom.xml to use that class ?

    • @RaghavPal
      @RaghavPal  2 года назад

      Hi Pavan, I will suggest, to now use WebDriver Manager and use chrome or firefox headless ruclips.net/video/8vWTgyoG0nc/видео.html

    • @100janyam
      @100janyam Год назад

      ​@@RaghavPal Will you explain how to use WDM for headless browsers. TIA

  • @arpitaverma8060
    @arpitaverma8060 5 лет назад +1

    Hi, Thanks for your videos. Could you please prepare videos for TestNg? And are your these videos sufficient to learn selenium. Thank you

    • @RaghavPal
      @RaghavPal  5 лет назад +1

      You're welcome Arpita, you will find TestNG in selenium framework playlist - automationstepbystep.com/online-courses/

  • @rajeshdevan6051
    @rajeshdevan6051 4 года назад

    Hi Raghav, I am getting this error Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
    at HtmlUnitDriverTest.main(HtmlUnitDriverTest.java:7)
    Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.SessionNotFoundException. I update html unit driver dependency latest version but still it is throwing exception. Please check this and reply me. Thank you.

    • @RaghavPal
      @RaghavPal  4 года назад +1

      Hi Rajesh, I will suggest to move forward with the next tutorial,. HTML Unit Driver is not used much these days and we have headless ver of chrome and firefox

    • @rajeshbe2234
      @rajeshbe2234 4 года назад

      @@RaghavPal Ya sure. Thank you Raghav.

  • @A.B.00007
    @A.B.00007 5 лет назад

    Exception in thread "main" java.lang.NoSuchFieldException: WebClient
    at java.lang.Class.getDeclaredField(Unknown Source)
    What to do with it here, ?? It prints out Title of that Selenium website but for all those Boolean checks for BrowserVersion() it shows this exception and nothing else!! any comments??

    • @RaghavPal
      @RaghavPal  5 лет назад

      Hi Asifuzzaman, nowadays HTML Unit driver is not very much used. You can try with Chrome headless for Firefox headless browsers for headless testing.

  • @dimplepal3583
    @dimplepal3583 3 года назад +1

    Hi Raghav, When I am trying to implement this code into my selenium project. I am not getting an option to import HtmlUnitDriver class option. Seems like some config is missing. Please advise. thanks!

    • @RaghavPal
      @RaghavPal  3 года назад +1

      Hi Dimple, HTMLUnitDriver is now not used, Skip and goto the next video

  • @sangamsood5651
    @sangamsood5651 4 года назад

    Hi i tried the same way as shown in video ,though added jar also (htmlunit-driver-2.42.0-jar-with-dependencies.jar,httpclient-osgi-4.3.jar.zip) but getting this error
    ----------------------------------------------------------
    Exception in thread "pool-1-thread-1" java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory.(Ljavax/net/ssl/SSLContext;[Ljava/lang/String;[Ljava/lang/String;Ljavax/net/ssl/HostnameVerifier;)V
    at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.(HtmlUnitSSLConnectionSocketFactory.java:123)
    at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.buildSSLSocketFactory(HtmlUnitSSLConnectionSocketFactory.java:112)

    • @RaghavPal
      @RaghavPal  4 года назад

      Hi Sangam, HTML Unit Driver is no longer used, You can skip this. Can use Chrome and Firefox headless browsers

  • @ilavarasansriraman4140
    @ilavarasansriraman4140 4 года назад

    Is we can take screenshot after using headless browser testing...

    • @RaghavPal
      @RaghavPal  4 года назад +1

      Yes Ilavarasan, but may not be in HTML Unit Driver, It is no longer used. Try Chrome or Firefox headless browsers

  • @neha7980
    @neha7980 3 года назад

    Sir Can you please raise li'il bit volume in videos,,,that'll be really helpful to us.Thankyou.

    • @RaghavPal
      @RaghavPal  3 года назад

      Noted Neha, I will take care in future videos, For now you can inc volume of system and youtube player, Can try using headphones

  • @knownothing1277
    @knownothing1277 7 лет назад

    I am trying to do HtmlUnitDriver but when I write HtmlUnitDriver under main class then it shows red underline and when I put my cursor there then it is not showing anything about import org.openqa.selenium.htmlunit.HtmlUnitDriver. For bring this import do I need to install anything or what shall I do to do that? Please help.

    • @RaghavPal
      @RaghavPal  7 лет назад

      Alok, have you taken selenium libraries. This is covered in earlier session on this series. Please check.

    • @RaghavPal
      @RaghavPal  7 лет назад

      Selenium Beginner 5 - How to write first Selenium script (java) - 5 Easy Steps
      ruclips.net/video/7yYDOja8n_k/видео.html

  • @engineernaveedrehman258
    @engineernaveedrehman258 4 года назад

    Hello sir where the link for you selenium course from scratch of udemy?
    Could@, you share it the selenium udemy course link over here.
    Thanks

    • @RaghavPal
      @RaghavPal  4 года назад

      Hi Naveed, can check Udemy courses here - automationstepbystep.com/udemy-discounts/

  • @PraveenReddyKalluri
    @PraveenReddyKalluri 4 года назад +1

    if we add the maven dependency then no need to downoad jar rig
    ht

    • @RaghavPal
      @RaghavPal  4 года назад

      Yes Praveen, you can check the Selenium Java Framework playlist here - automationstepbystep.com/

    • @PraveenReddyKalluri
      @PraveenReddyKalluri 4 года назад

      But get method not coming

    • @RaghavPal
      @RaghavPal  4 года назад +1

      Praveen, you can skip this session as HTML Unit Driver may not be updated

    • @PraveenReddyKalluri
      @PraveenReddyKalluri 4 года назад

      @@RaghavPal ok thankQ i just known that's enough

  • @parvati-putra
    @parvati-putra 8 месяцев назад

    when i use this htmlunitdriver i'm getting nosuchelementexception please help me sir

    • @RaghavPal
      @RaghavPal  8 месяцев назад

      Parvati
      The `NoSuchElementException` in Selenium occurs when an element cannot be found on the page. Let's explore some common reasons for this exception and how to handle it effectively:
      1. Dynamic Loading of Elements:
      - Dynamic websites often load elements asynchronously and at varying rates.
      - If an element is not loaded instantly, WebDriver may throw a `NoSuchElementException`.
      - Solution: Wait for the element to be available before interacting with it. You can use explicit waits (e.g., `WebDriverWait`) to ensure the element is visible
      2. Incorrect Locator Strategy:
      - Ensure that you are using the correct locator strategy (e.g., XPath, CSS selector, etc.) to find the element.
      - Double-check the expression from your source code, including any spaces.
      - Verify the expression using Try XPath to avoid this exception
      3. Page Load Timing:
      - Sometimes the page may not load completely when you try to find an element.
      - Set an appropriate page load timeout using `driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS)`
      4. Element Visibility:
      - The element might not be visible on the screen.
      - Scroll down or up to bring the element into view before interacting with it
      5. Graceful Exception Handling:
      - Use a try-catch block to handle the exception gracefully.
      - For example, create a generic method to check if an element is present:
      ```java
      public boolean isElementPresent(By by) {
      boolean isPresent = true;
      try {
      driver.findElement(by);
      } catch (NoSuchElementException e) {
      isPresent = false;
      }
      return isPresent;
      }
      ```
      - This way, your test won't fail abruptly when an element is not found
      Remember that NoSuchElementException is an unchecked exception, so handling it gracefully within your code is essential for reliable and robust test automation. Happy testing

    • @parvati-putra
      @parvati-putra 8 месяцев назад

      sir it's only happening with the headless browser even after using waits@@RaghavPal

    • @RaghavPal
      @RaghavPal  8 месяцев назад

      will need to check this in detail.. can try some online examples and let me know detailed steps

    • @parvati-putra
      @parvati-putra 8 месяцев назад

      I was automating orangehrm demo website using chromedriver everything was fine but when I used htmlunitdriver to try headless browser it throws nosuchelementexception there was also no problem with using chromeoptions to make chromedriver a headless browser. what i understood is may be htmlunitdriver is deprecated that's why it is not working properly@@RaghavPal

    • @RaghavPal
      @RaghavPal  8 месяцев назад

      Parvati
      pls check if this is this also coming with chrome headless
      can try adding extra waits or explicit waits

  • @nisheethbaxi6208
    @nisheethbaxi6208 5 лет назад

    What would be the syntax for BrowserVersion.Firefox in Python? Please help

    • @RaghavPal
      @RaghavPal  5 лет назад

      Hi Nisheeth, you can watch the python videos ruclips.net/p/PLhW3qG5bs-L9JjtXx-adxWdbjaxeRhi7h

  • @nitesh2311
    @nitesh2311 7 лет назад

    I'm not able to handle more than one window using HtmlUnitDriver, I had used driver.windowHandles() but when I switch to the second window I get ArrayIndexOutOfBound exception. Can you please help me out

    • @RaghavPal
      @RaghavPal  7 лет назад

      Hi Nitesh, check if this helps - groups.google.com/forum/#!topic/webdriver/uRXsoh9fEZI
      Also i will suggest to use PhantomJS

  • @adambordelon787
    @adambordelon787 6 лет назад

    I get script errors how can i fix that error can you help me about that

    • @RaghavPal
      @RaghavPal  6 лет назад

      Hi Adam, what exactly is the error. Do you have logs.

    • @adambordelon787
      @adambordelon787 6 лет назад

      I was using jsoup but there was a problem that the website i try to scrap can get my location but i want to get html for different location i used useragent and i change location from browser but didnt work is there a way to do that without proxy of course

    • @RaghavPal
      @RaghavPal  6 лет назад

      Sorry Adam, No idea on this.

  • @rajeshdevan6051
    @rajeshdevan6051 4 года назад

    Raghav please say main thing you missed out to say this HtmlUnitDriver is not available in selenium 3.x version.
    HtmlUnitDriver to use this concept, we have to download htmlunitdriver JAR file github.com/SeleniumHQ/htmlunit-driver/releases
    . I have spent lot time to find this solution. I know you are a great man to teaching but in some case you missed out the main step before do the logic. So i hope my comment will not be taken any mistake reg this topic.

    • @RaghavPal
      @RaghavPal  4 года назад +1

      Hi Rajesh, thanks for your inputs. May be there are updates since the video was recorded. I will add this in description

    • @rajeshbe2234
      @rajeshbe2234 4 года назад

      @@RaghavPal Ok Raghav. Thank you. I will be watching your videos ever.

  • @abyanfaishal
    @abyanfaishal 6 лет назад

    How to extract a javascript with htmlUnit

    • @RaghavPal
      @RaghavPal  6 лет назад

      Hi Abyan, although I have not tried this practically, here is a link that can help - stackoverflow.com/questions/2961965/accessing-html-generated-by-javascript-with-htmlunit-java

  • @loveandlike6747
    @loveandlike6747 3 года назад

    Dear teacher I really love your lessons you are the best teacher I have ever seen.
    Can you please tell me is there any free anti virus, that I can use for computer?

    • @RaghavPal
      @RaghavPal  3 года назад

      Thanks for the kind words, on anti-virus I am not sure which free one is the best, will need to check online

    • @loveandlike6747
      @loveandlike6747 3 года назад

      @@RaghavPal dear brother
      How can I get xpath or css if there is no attributes on that

    • @RaghavPal
      @RaghavPal  3 года назад

      I will plan a session on this

  • @y.c.breddy3153
    @y.c.breddy3153 5 лет назад

    How to enable the Google chrome or Internet explorer in selenium webdriver?
    How to python used in selenium?
    Which package used in selenium webdriver?

    • @RaghavPal
      @RaghavPal  5 лет назад

      Hi, you will get all these answers in the Selenium series, can find it here - automationstepbystep.com/online-courses/