INTRO:
I am a student using Java Selenium for GUI testing. I cannot get test cases to run on my desktop but other members of my team are able to.
WHAT TECH/SOFTWARE IS BEING USED
We are using JDK 14, IntelliJ Community Edition, BitBucket for our repo, and JUnit 4.
WHAT AM I TESTING
I am testing a sample single page application. I add a task, use a date picker to add a date, and then I click the "Add Item" button. However the click to the button isn't registered and the task isn't added to the list. If I restart my computer the first #Test works but the second one fails to clear the cookies and the second #Test fails.
DETAILED VERSION:
I am coming from a Surface Book 2 to a Alienware R10 desktop. My team was able to pull the project and run all of the test cases with no problem. However, I was unable to. The same program works on my SB2 but not on the Alienware R10 (AMD 3900 Processor).
WHAT I HAVE TRIED:
I used both a locally stored Chrome Driver and I used Boni Garcia's
WebDriverManager.
The project is built using Maven so I have tried to use both
dependencies and also add the selenium files directly to my project
structure with no success.
I reformatted my new R10 and tried to install everything again. I
carefully added the JAVA_HOME and MAVEN_HOME to my system path.
I tried to use ChromeOptions after seeing some posts on SOF and none
of those worked either.
The QA dev who leads us tried to help me for about 40 minutes and
couldn't figure it out. He said the problem isn't with my IDE but it
is with the Chrome cookies. I will have to clear the cookies every
time I want to run a JUnit Selenium test. However, other members of
my team do not have to do this and this doesn't always work.
EXTRA DETAILS:
I got a new Alienware R10 with the AMD Ryzen 3900 chip. I have added
JAVA_HOME and MAVEN_HOME to my Path and environmental variables.
I may be adding to the project structure or dependencies incorrectly.
This is my first post so please let me know if I should format the
question better or if I left any important details out.
CONCLUSION
I am pretty worried I wanted to study and practice over the weekend but I have put a lot of time into fixing this. My next idea is to use Eclipse instead of IntelliJ and see if I can get it running there. Any advice here would be helpful.
EDIT
Eclipse is not working either and has the same problem. This tells me the problem is definitely not related to the IDE. It is likely a CPU or Browser related issue. I also tried using other drivers through the WebDriverManger dependency.
Upon further research it seems to register clicks and actually add to the Tasks if I add a few Thread.sleep() functions into my code instead of the ExpectedConditions and element visability. The problem may be stemming from using the ExpectedConditions API but again this is working for my teammates and not for me. Could this potentially be a AMD chipset issue?
The element visibility may be the wrong function to use here but it did work on my teammates machines so that is why I didn't try to look for an alternative there. The function we are using looks at the DOM tree and we may instead want to see the visibility on the browser instead. I had difficulty testing this out as I didn't have a laptop to work with.
I reformatted my old laptop so it could be sold since I had this new PC set up but I will use it to try another function to see if it brings a different result.
EDIT2:
Observation/Guess
I am going to guess the problem is with the AMD 3900 CPU. The Thread.sleep() changes the behaviour to at least click my 'Add Item' button. It still does fail the tests I put it through and the ExpectedConditions API still doesn't work.
I am going to be returning the Alienware R10 and going to get an intel CPU R10 or build my own PC.
This is just an educated guess based on the difference in the behavior seen between my and myteammates' machines they have intel I have AMD.
If you are facing a similar issue please confirm whether you are using AMD or Intel in this thread. It will help others as well. I'm sure there are work arounds but they did not work for me. I also tried using ChromeOptions to disable the GPU and a few other options.
However there was no success and unless there is a better answer I'm blaming the AMD 3900 CPU.
Thanks and please contribute to this thread if you are facing a similar issue or have found a better answer. Any speculation could be helpful too.
I agree with the QA on your team.
This is not IDE related. I would suspect that manipulating the DesiredCapabilities of the WebDriver would resolve this issue. Given that you are using the bonigarcia WebDriverManager dependency, I would recommend atleat attempting the code below to see if the WebDriver can be created properly.
public static void main(String[] args) {
WebDriverManager.chromedriver().setup();
DesiredCapabilities chromeDesiredCapabilities = DesiredCapabilities.chrome();
WebDriver webdriver = new ChromeDriver(chromeDesiredCapabilities)
}
Related
I have a project where I need to download an audio file in ChromeDriver. The behavior here is different from in regular Chrome, where if I visit the URL, it'll automatically start downloading a file. If I do the same thing manually in ChromeDriver, it will not download the file.
I've tried different configurations of the chrome options/preferences. I've also found options that worked with old versions of chrome, that no longer work anymore.
Here is one of the better resources I found, but it still didn't work, even with their updated blog post
https://dkage.wordpress.com/2012/03/10/mid-air-trick-make-selenium-download-files/
When I attempt to use his solution, my chromedriver abruptly crashes itself in a non chrome-esque way. It just disappears. Not "Something went wrong" page like you'd normally expect. I end up with Java not being able to find my Session, cause it stopped existing.
Has anyone been successful at downloading files through Selenium webdriver in Chrome? If I need to use another browser, I can.
I'm currently using Chrome Canary.
I have the same problem. One solution that might work is to use another library, that is able to operate outside of the browser. I found these stackoverflow post discussiong this issue:
https://sqa.stackexchange.com/questions/2197/how-to-download-a-file-using-seleniums-webdriver
it contains this blogpost wich gives you some sugestions.
https://blog.codecentric.de/en/2010/07/file-downloads-with-selenium-mission-impossible/
Window automation
The first approach smells like “brute force”: when searching the net for a solution to the problem, you easily end up with suggestions, to control the native window with some window automation software like AutoIt. Means you have to prepare AutoIt such, that it waits for any browser download dialog, the point at which Selenium is giving up, takes control of the window, saves the file, and closes the window. After that Selenium can continue as usual.
This might eventually work, but I found it to be techical overkill. And as it turned out, there was a much simpler solution to the problem.
Change the browsers default behaviour
The second possibility is to change the default behaviour of the browser. When clicking on a PDF for example, the browser should not open a dialog and ask the user what to do with the file, but rather save it without comments and questions in a predefined directory. To accomplish that, a file download has to be initiated manually, saved to disk and marked as the default behaviour for these file types from now on.
Well, that could work. You “only” have to assure that all developers, hudson instances, etc. share the same browser profile. And depending on the amount of different file types, that could be some manual work.
Direct download
Taking a step back, why do we want to download the file with Selenium in the first place? Wouldn’t it be much cooler, to download the file without Selenium, but rather with wget? You would have solved the second problem as you go. Seems a good idea, since wget is not only available for Linux but also for Windows.
Problem solved? Not quite: what about files, that are not freely accessible? What, when I first need to create some state with Selenium in order to access a generated file? The solution seems ok for public files, but is not applicable for all situations.
Can anyone please help me with Selenium + Java + IE + Windows code and settings to be done step by step? There are so many conflicting answers over the web and none of those is working (due to lack of my understanding perhaps, I am basically shell and python programmer and shifted to test automation recently). Please help me with code and required settings. Screenshots of settings will be highly appreciated (I am new to windows as a programming environment, I have extensive command line programming experience on *nix systems on shell and python as mentioned earlier).
The problem is that the "Internet Explorer" window is opened, however the test cases are not executed at all and after waiting for some time the Eclipse console shows error.
Thanks,
P Ashwin
Ensure you download the IE Driver Server. You'll need 32 bit or 64 bit to match your OSes "bitness."
The executable should be on your path. You can point to it in code as Aramin called out above; however, I prefer to have the executable on the path--doing it in code is just one more configuration mess you have to deal with if you run on different systems.
Note that you'll need to restart any shells/command windows after you add the server's executable to your system environment variables.
After that it's just a matter of firing it up in code and looks like any other WebDriver:
WebDriver browser;
public void initialize() {
browser = new InternetExplorerDriver();
browser.navigate().to("http://the-internet.herokuapp.com");
}
Note: This is from a canned set of demos I use for training. It runs under Cucumber, normally with an #Before tag. I took that out to avoid confusion.
HTH
Code :
System.setProperty("webdriver.ie.driver", "D:\\IEDriverServer.exe");
WebDriver driver= new InternetExplorerDriver();
driver.get("http://www.w3schools.com");
Along with this you need to enable scripting for IE(Internet Options->Security->Custom level ) as shown in ]1
Hope this will help you..
I am newbie in automation world. Recently, I created some automation script for my work. Its working good. The problems that I am facing are:
This script work in normal speed in my machine but if i use the same script in my friend's computer, its super super fast. So fast that its braking the automation steps.
This automation works good on my machine with Firefox driver but if i try to use Chrome driver, again its super super fast that it breaks the automation step.
Is there any solution for this? Why automation acts differently in different machine? Is there a way to configure the speed.,..?
Yes kiran you can add explict wait. Please find the code below :
WebDriverWait wait= new WebDriverWait(driver,20 );// Explicit wait()
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("xyz")));
you must be using different driver exes with different machine.. I have observed pathetic performance while using IEdriver for 64 bit. Try using same webdriver exes on both the machines. Thanks!
Dear if it work fast its good but if its getting failed because of not fining the particular field you are locating, in that case you can use the Implicit or Explicit wait so that the your driver should wait until it doesn't found particular item you are locating.
You can also use Thread.sleep(5000) but that is not a good practice.
I've got a little test suite working on my laptop which I've tried to transfer over to my work desktop. To, hopefully, make things easier, I used the same version of Java and maven. However, typically, it's not been so easy :)
When I started Firefox, I got a "Firefox has stopped working" message box. The message box indicated the issue lay with "xul.dll" - so I closed the box and Firefox opened. It does this everytime I open Firefox.
I have even stripped out all my allure and other code and just ran a simple case:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.co.uk");
However this doesn't work either.
It was then I checked the versions of Firefox were the same, turns out they weren't - but the Firefox updated fixed that. But my test still passes on the laptop, but fails on the desktop. I can't see anything I have missed, I can see one possible issue - the work desktop has Kaspersky installed.
Has anyone ever experienced what I've described?
I have also observed that antivirus causes the Firefox to hang during the launch. Try disabling the antivirus and rerun your script to verify that in your case also the antivirus/firewall is causing the issue.
Check the version of Firefox on both computers. I have two Windows machines with Selenium 2.45.0. One machine has Firefox 37.0.2 and the code below executes fine. The other machine I just updated to Firefox 38.0.1 and I receive that error message box.
#Test
public void testFirefoxDriver() throws Throwable
{
new FirefoxDriver();
}
I've been using Selenium for over a year now. Our production server automatically updates Firefox and this occasionally causes incompatibilities between Firefox and Selenium. I would expect to see a new Selenium release very soon.
Firefox 38.x is not supported by Selenium 2.45.1. Either you have to roll back your firefox to 37.x or wait until next revision of Selenium.
https://github.com/SeleniumHQ/selenium/issues/437
I've got this same issue. Funnily enough it was working yesterday morning I started getting it yesterday afternoon and now it appears to be messing up my tests.
I have Selenium 2.45.0 & Firefox 38.0.1.
My tests were running perfectly before this started happening and nothing has changed in my code. I've also ran another test suite just to make sure that it wasn't the one I was working on. The same thing happened.
I've just uninstalled firefox downloaded the previous version and they now work again with no crash.
I am working on a demo for a client of what's possible with GWT-Ext for GWT. After browsing for the simplest way to get up and running, I decided on installing the Google Plugin for Eclipse and using the New Web Application Wizard.
First time around, I followed these steps for create the default application:
Selected File > New > Web Application Project from the Eclipse menu.
In the New Web Application Project wizard, entered a name for the project (ExtDemo) and a java package name, com.extdemo.
Unchecked the "Use Google App Engine" check box.
Clicked Finish.
Right clicked it in package explorer and selected Run As > Run Configurations
Put a check in the Automatically Select Unused Port checkbox.
Clicked Run to see the default GWT 1.7 application
This worked fine... it launched GWT's hosted browser and the app worked as supposed to.
(I then continued to import GWT-Ext and add all sorts of widgets building up a nice little demo app)
However at some point when relaunching the app in hosted mode, the hosted browser displays an empty iframe. I even reverted the code to a point where everything was working as supposed to and... same thing, an empty iframe with the surrounding static content.
Now what is really strange is when I go through the process of creating the default application again by following the steps above, the hosted browser launches with an empty iframe again.
However when I click on Compile/Browse, this sometimes allows the app to launch in Firefox.
Anyone have this happen to them?
I have seen some odd behaviors occasionally. Here are some basic suggestions (some are dumb and you might have tried them already):
Use a new workspace
I do not know if GWT plugin somehow caches stuff in the embedded Jetty. If you are re-creating the default app/project, try and use a different name for the project.
Try and re-use a fixed port so that there is no possibility of having multiple servers running.
Update: Found a new "classic" solution:
Delete the cache in IE and possibly Firefox too. Apparently the 'script' tag content tends to be cached by IE. If this works, we can all try tearing our hair out!
Found the updated answer at this link:
I have had the same problem in the past and found it is much more likely to happen if limited CPU is available. For example if my older laptop was running on battery and had stepped down the CPU speed to save power it frequently happened. When running on mains in max performance mode it only happened occasionally. Now I have a much newer and more powerful laptop and the problem has gone away.
Another cause I found was too many breakpoints set up in eclipse and removing breakpoints would often clear the problem.
I've had issues with the browser caching.
Try clearing your browser cache, refresh a few times after a failed load, etc.
You can also try using a different port so the URL is different.
It takes some time to download and run the GWT app, particularly if you are using extra libraries, so wait for a few seconds to see if the app finally loaded.
What makes the app loading to fail randomly is something I don't know yet, but I suspect, as stated by Daniel Vaughan, that is related with a lack of computer resources, CPU, memory, etc.