I am using Selenium script (in Java) with Jenkins using Chrome browser.
But Jenkins opens Chrome browser with dimension 1040x784, although I tried to increase dimension as desktop browser but failed, it still opens browser with dimensions 1040x784.
I am using this code to increase dimension:
Dimension dim=new Dimension(1340, 744);
driver.manage().window().setSize(dim);
So in order to open chrome browser with desktop dimension, do I need to add any plugin? Due to this I am not able to automate most of the features with Jenkins.
* I am using Jenkins as my Windows services.
I use the same code as you with jenkins without problem: windows is set to its new size as expected.
I think the issue might be that Chrome does not allow to set the size larger than the dimension of the system's screen.
If you know for sure that your system's screen allows you to reach [1340, 744], then it might be because your chrome driver is not an up to date version.
If it still does not work, below are some tests you might try, to fix the issue:
Try to run it with firefox webdriver, and see if you have the same issue. this will discard an issue related to chrome webdriver.
Try to set new dimension, but smaller than the 1040, 784, and see if chrome lets you do that. It will discard an issue related to the way you have written your code.
does it work fine when you execute it on local ?
Related
I have my regression suite setup in jenkins and it executes on windows server 2012 r2. Recently I changed screen resolution to 1920,1080 by using below code
driver.manage().window().setSize(new Dimension(1920,1080));
All the other test scripts get passed except two ( let's say script1 and script2 ) in headless mode on the server. But those two scrips get passed in my local machine in both headless and browser mode.
And also when I execute those two scripts in browser mode on the server with the same screen resolution, again they get passed.
When I change the screen resolution to
driver.manage().window().setSize(new Dimension(1366,768)); It get passed on the server in headless mode.
Since I'm using the same configurations for the rest of the scripts. I couldn't think of an exact thing happening here. When I build the Jenkins job, it executes all the other scripts and when it comes to script1 execution hangs. Jenkins build also hangs and doesn't come to the end. Looking for a solution for this.
I'm using webdrivermanager and chrome version of the server is 96
By default, VM screen size is very small (--window-size=1040,784), so while automating things, decrease your screen size to this value and automate, otherwise, we will face this issue.
To increase VM screen size, you need to increase virtual memory of your R2 server. that will end up with high cost.
solution:
Automate with smaller screen size.
or Run it in headless mode
I did troubleshoot and here are my findings,
It was a loop which was never ending if element not found
inside the loop, it searches for an element which was appeared only in a small screen resolutions (arrow button to navigate through some tabs. when the screen resolution is higher, all the tabs appear in the page and no arrow button visible)
So that's the reason those scripts work in small screen resolution and failed in higher resolutions
I changed the loop accordingly and now I can execute all the scripts with higher resolution on the server with headless mode
I am connecting a standalone program to a website, and I have to read some pages of the website. For first, I used Jsoup, but with this I discovered that some informations that I need are loaded after page load, so I searched for webdrivers. (I am not looking for images or something big, my content are all textual)
Now, i found the ChromeDriver, but it is too slow for my case because it has a lot of options and features.
In my case I need just a step more than the Jsoup possibilities.
It is possible to disable the best part of ChromeDriver options and features to reach this goal?
For example, i saw plugin disabling, but is one by one and is not for every chrome browser on every pc. I didn't found an option like "plugin.disable-all".
Furthermore,in this way I cannot open more than a few instance of chromedriver. In this moment, every instance of the chromedriver is opening a Google Chrome Helper that uses 100Mb of ram.
Hope all is clear
HtmlUnit might be enough for your needs. It does support some Javascript.
It can be used with Webdriver. But might as well be enough on its own
To make your webdriver run faster (but not that much faster), you can run the driver in Headless mode. See these articles for a tutorial on how to go into Headless mode for Chrome.
Before starting the driver, add the --headless argument to ChromeOptions.
Headless mode can speed up your automation by not rendering the browser window, but keep in mind that doing a straight HTTP GET with JSoup would always be faster.
My advice would be to reverse engineer the page a bit more, and see if you can figure out how to query directly whatever the (presumably AJAX) calls are putting on the page. If you can treat those specific requests as an API and only query for exactly what you want, you will be able to get results faster than with browser automation through Selenium.
I have a selenium (v2.53) test that visits a site containing flash player (I'm testing this player). up until now, everything was working fine, but after I updated chrome to v62, flash is disabled by default.
I can't change manually flash setting since this test is automated and running on remote machines.
I've tried adding some chrome capabilities that should work on previous versions of chrome, but it did not work on chrome 62 version since allowing flash is not enough, now a list of allowed site is also required.
How can I change both the enabled status and the list of sites using selenium?
Also, is there a way to install chrome with a config file that both enables flash and populates the required sites list?
Thanks.
P.S. I'm working with Java 8
Your best bet is to simply use Chrome options. Why do you need a config file? That sounds overly complicated and unnecessary. You can enable it through chrome preferences. Try a fresh install of Chrome too.
Something akin to the likes of:
chromeOptions:{
args: ["--allow-running-insecure-content", "--allow-insecure-websocket-from-https-origin", "allow-outdated-plugins"]
You didn't specify which language so I can't give you a language example.
As mentioned in the below blog, we can modify screen resolution during selenium test runs.
http://blog.testingbot.com/2013/03/15/screen-resolution-option-now-available-for-all-selenium-tests
Tried the below code(as mentioned in "https://saucelabs.com/docs/additional-config"), but not setting the specified resolution. Is this still not available for Selenium?
DesiredCapabilities dc=new DesiredCapabilities();
dc.setCapability("screen-resolution","1280x1024");
Sauce Labs != Selenium
Sauce labs use that capability to provision you a VM with the desired resolution, it's not a capability that Selenium itself knows about.
Selenium is not capable of modifying your desktop resolution!
If you want to modify your browser size in Selenium so that it matches a specific resolution you can do a:
driver.manage().window().setSize(new Dimension(1024, 768))
The above is not supported with Opera driver, so instead you would need to do:
DesiredCapabilities capabilities = DesiredCapabilities.opera()
capabilities.setCapability("opera.arguments", "-screenwidth 1024 -screenheight 768")
While setting the browser size is not the same as setting the screen resolution, it should for all intents and purposes meet your requirements.
Selenium is a browser automation framework, its job is to drive a browser, not to automate your system. I don't think that a functionality such as setting a screen resolution will ever be implemented in Selenium. Setting resolution has simply nothing to do with browser automation.
I am not sure why do you want to change the resolution... How about just changing the size of your browser window? That's something you could do if you are testing responsive-designed pages.
driver.manage().window().setSize(new Dimension(800, 600));
The purpose of DesiredCapabilities is to tell the Grid where to run your tests.
So, if there is a remote node connected to the Grid with the resolution you specified 1280x1024, the test will run on that node. If any other nodes do not have this resolution, the test will not run on those nodes.
If you do not specify a screen resolution in the DesiredCapabilities, the test will run on nodes with any resolution.
This feature of Selenium does not actually change or modify a testing node's screen resolution. It only tells the Grid on which nodes to run or not run your tests.
What you are interested in doing is probably best done through native java code rather than through Selenium which is a web browser testing framework.
The question of changing the resolution through Java was addressed in another thread here on StackOverflow.
swing - Change screen resolution in Java
Although I am curious as to why you are trying to do this, since you didn't explain that above and may lead to a better response from the community. =)
I am using Selenium 2.32, Java JDK 1.6.0_07, IE9 with Windows 7. Here is the problem
When i use IE WebDriver 32 Bit and click on a link which opens a new browser containing PDF, the PDF is opened in the browser itself which is fine, but the new browser is not identified when i use driver.getWindowHandles(). It always returns only the parent window. When i use the same code with IE8, it works perfectly fine and i am able to get the URL of the new browser.
I thought since it is Windows 7 and IE9, i should use IE Webdriver 64 bit and so i used IE Webdriver version 2.32.3 (64 Bit). With this webdriver, when i click on the link, the new browser pops up but the PDF is not opened in the browser and instead it is opened as a separate PDF file. Even in this case, the new browser is not identified and driver.getWindowHandles() returns only one browser.
Not just the PDF browsers but also the normal browsers are not returned by driver.getWindowHandles()
I am using a wait of 10 seconds for the new browser to load and so the there is no load/sync issue.
I want to identify the new browser and get the URL of the new browser. Please help.
The problem here is that you are making things too complicated. From your comments, it does not seem you are doing things the "typical" and "recommended" way. If you are following advice, then you are doing it the slightly harder route. My advice is still to simplify further.
If I were to guess on your issue though: I notice that you say you are using "IEDriverServer". That tells me that you may be improperly using WebDriver. When you are using a Grid Hub and a separate Grid Node ( see my link here for sample launch instructions: https://gist.github.com/djangofan/5174433 ) then you should be invoking RemoteWebDriver rather than WebDriver, like so (or similar):
WebDriver driver = new RemoteWebDriver (
new URL("http://localhost:4444/wd/hub"),
DesiredCapabilities.firefox()
);
driver.get("http://www.google.com");
This work for me:
Root cause: On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".
Hope it works for you.