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();
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 ?
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.
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
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.
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.
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
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.
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.
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
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??
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!
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)
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.
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
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
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
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
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.
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
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?
Don't forget to add htmlunit driver jar to build path :)
how to download jars files fro htmlunit driver
Thanks a lot bro. Please keep sharing more videos. Your approach is very practical
Thanks for watching
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();
Using the above will emulate chrome browser
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 ?
Hi Chandra, I believe HtmlUnitDriver is no longer used. You can skip this
Hi Raghav,
Do you mean to say that i can skip chapter 13 and can continue with next ?
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.
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
I will do that soon Smana. You can see other playlists here - ruclips.net/channel/UCTt7pyY-o0eltq14glaG5dgplaylists
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.
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.
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.
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.
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.
Keep Learning :)
I am unable to import the HtmlUnitDriver driver so can't run it. That option is not available for me
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
Hi Raghav,
i am getting this error
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices
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.
Hi raghav do we need to add htmlunitdriver dependency in pom.xml to use that class ?
Hi Pavan, I will suggest, to now use WebDriver Manager and use chrome or firefox headless ruclips.net/video/8vWTgyoG0nc/видео.html
@@RaghavPal Will you explain how to use WDM for headless browsers. TIA
Hi, Thanks for your videos. Could you please prepare videos for TestNg? And are your these videos sufficient to learn selenium. Thank you
You're welcome Arpita, you will find TestNG in selenium framework playlist - automationstepbystep.com/online-courses/
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.
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
@@RaghavPal Ya sure. Thank you Raghav.
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??
Hi Asifuzzaman, nowadays HTML Unit driver is not very much used. You can try with Chrome headless for Firefox headless browsers for headless testing.
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!
Hi Dimple, HTMLUnitDriver is now not used, Skip and goto the next video
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)
Hi Sangam, HTML Unit Driver is no longer used, You can skip this. Can use Chrome and Firefox headless browsers
Is we can take screenshot after using headless browser testing...
Yes Ilavarasan, but may not be in HTML Unit Driver, It is no longer used. Try Chrome or Firefox headless browsers
Sir Can you please raise li'il bit volume in videos,,,that'll be really helpful to us.Thankyou.
Noted Neha, I will take care in future videos, For now you can inc volume of system and youtube player, Can try using headphones
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.
Alok, have you taken selenium libraries. This is covered in earlier session on this series. Please check.
Selenium Beginner 5 - How to write first Selenium script (java) - 5 Easy Steps
ruclips.net/video/7yYDOja8n_k/видео.html
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
Hi Naveed, can check Udemy courses here - automationstepbystep.com/udemy-discounts/
if we add the maven dependency then no need to downoad jar rig
ht
Yes Praveen, you can check the Selenium Java Framework playlist here - automationstepbystep.com/
But get method not coming
Praveen, you can skip this session as HTML Unit Driver may not be updated
@@RaghavPal ok thankQ i just known that's enough
when i use this htmlunitdriver i'm getting nosuchelementexception please help me sir
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
sir it's only happening with the headless browser even after using waits@@RaghavPal
will need to check this in detail.. can try some online examples and let me know detailed steps
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
Parvati
pls check if this is this also coming with chrome headless
can try adding extra waits or explicit waits
What would be the syntax for BrowserVersion.Firefox in Python? Please help
Hi Nisheeth, you can watch the python videos ruclips.net/p/PLhW3qG5bs-L9JjtXx-adxWdbjaxeRhi7h
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
Hi Nitesh, check if this helps - groups.google.com/forum/#!topic/webdriver/uRXsoh9fEZI
Also i will suggest to use PhantomJS
I get script errors how can i fix that error can you help me about that
Hi Adam, what exactly is the error. Do you have logs.
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
Sorry Adam, No idea on this.
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.
Hi Rajesh, thanks for your inputs. May be there are updates since the video was recorded. I will add this in description
@@RaghavPal Ok Raghav. Thank you. I will be watching your videos ever.
How to extract a javascript with htmlUnit
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
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?
Thanks for the kind words, on anti-virus I am not sure which free one is the best, will need to check online
@@RaghavPal dear brother
How can I get xpath or css if there is no attributes on that
I will plan a session on this
How to enable the Google chrome or Internet explorer in selenium webdriver?
How to python used in selenium?
Which package used in selenium webdriver?
Hi, you will get all these answers in the Selenium series, can find it here - automationstepbystep.com/online-courses/