I have a situation here that we have a webGL dependent application to automate. i have automated the whole application on my laptop, and this application is running fine on chrome on my laptop. but the issue is when i run this application from a seperate machine which is a selenium GRID node. It gives me a message that the application required Webgl and and it ask me to enable the webGL. i have tried different methods like selenium option and ignoring the chrome black list as well.
when i open the browser manually and open the application it runs find and i checked on url chrome://gpu. it shows that the gpu is enaled.
but when i invoke the selenium and run the test cases,. the browser initiates with WebGl as disabled
i found the solution to this. here is the code you can use to enable WebGL for chrome.
DesiredCapabilities capability = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
**options.addArguments("--ignore-gpu-blacklist");**
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability("chrome.binary", "C:\\Temp\\chromedriver.exe");
capability.setVersion("9999");
capability.setCapability(ChromeOptions.CAPABILITY, options);
return new RemoteWebDriver(HUB_URL,capability);
Related
Need to test responsive design for web app. I understand that browser didn't emulate like real device or even device emulator, but i don't need it.
Note: i'm looking for not to run Safari inside emulator, but to activate mobile emulation in Safari
question 1:
Is it possible to start Safari via selenium with predefined mobile emulation, like in Chrome here
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Nexus 5");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
WebDriver driver = new ChromeDriver(chromeOptions);
if answer no(assume it will be no), question 2:
is it enough to resize Safari window to required device viewport size?
Setting the browser width isn't enough as many of today's web pages use the useragent as a means to determine the device that is viewing the page. Afaik, there is no way and I've been trying to find a solution to this for a while. Safari doesn't give automated control to set the user agent nor the mobile mode of its desktop browser.
There is a way to do what you want here though: https://webkit.org/blog/9395/webdriver-is-coming-to-safari-in-ios-13/
But the requirement is you need an iPhone connected to your laptop to run the test from and you need to add these capabilities to your configuration
safari:deviceType
safari:useSimulator
Read the man file for safaridriver for more info.
If you need to set the useragent, you can do it via the command line, but you need to reset it after https://tarunlalwani.com/post/selenium-change-user-agent-different-browsers/
I have few selenium test cases; running fine on desktop website. My website is responsive; hence works fine on Mobile Browser also. How do I test my test cases on Mobile Browser ?
If your requirement is to test your site in Mobile view (As your site is responsive) then following code may help you -
FirefoxProfile ffprofile = new FirefoxProfile();
ffprofile.setPreference("general.useragent.override", "iPhone"); //this will change the user agent which will open mobile browser
WebDriver driver = new FirefoxDriver(ffprofile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(360,640)); //just to change the window size so that it will look like mobile
driver.get(siteURL);
You can use Appium to support the
Mobile web apps are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome or the built-in ‘Browser’ app on Android).
Its design is based on the WebDriver API, so you’re free to use whatever test runner and test framework you already have. Keeping this in mind, your current Test engine should be insensitive to the application drivers and those are just plug&play “automation libraries” anyway.
Here is the Appium GitHub examples repo, which I like to use. You can find examples in:
RobotFramework
dotnet
java
node
perl
php
python
ruby
Our Selenium WebDriver tests are run remotely in TeamCity on a Windows server 2012 EC2 instance.
I am unable to resize the browser when using chrome on this instance. It works fine with Firefox, but chrome is stuck in 1024 X 768.
I have tried the following methods to resize, but none have worked.
ChromeOptions options = new ChromeOptions();
options.AddArgument("--start-maximized")
WebDriver.Current.Manage().Window.Size = new Size(width, height);
ChromeOptions options = new ChromeOptions();
options.AddArgument("window-size=1920,1080");
all methods work locally on windows 10, with chrome version 49.0.2623.110 and chrome driver version 2.9 on both machines.
Is there any way to resize the chrome browser I haven't tried, or is this a chromedriver issue?
Can you try this
driver.manage().window().setSize(new Dimension(1920, 1080));
By default maximum size of our chrome window is (1040, 784). setting windows size will not work directly. instead you need to do Following actions,
we need to increase the Virtual memory of the EC2 instance.
or open your chrome in headless mode and then set your screen size in your chrome option.
same issue happened for me. I resolved by 2nd option because increasing instance will increase the cost.
I am running Selenium automation test in one browser, but at the same time, I want to open the browser in another window and do something like checking mail, googling email then active mode or focus is coming to the current working window, not the automation test run browser.
Is it possible to work on the browser while automation test is run?
In general, when doing UI automation, you cannot use the test machine to do any other tasks that involve using the keyboard or mouse.
Since WebDriver automation performs keyboard and mouse input, such as typing text and clicking items, you will be constantly interfering by taking focus away from the WebDriver instance of the browser and doing your own mouse and keyboard interaction in other applications.
This will adversely affect both you and the automation, with neither being able to do what they want to do!
You should either use a separate test machine, or setup a virtual machine using software such as VirtualBox (free).
Did you try doing that?
Selenium uses WebDriver to communicate with a specific instance of a browser, not the currently focused window. So you should be able do continue to use other instances of browser windows. The best thing to do would be try.
If it isn't working, I would recommend getting a VM up and running and using that as your test environment. Generally that is the way I work to keep everything separate.
I ran my tests on Firefox and then used chrome on the side. Otherwise, run your tests on a remote machine.
You can do 2 things
1. Use a third tool to run test cases like Jenkins. so that test will run in memory.
2. If you are using firefox you can create a seperate firefox profile so that if you use firefox at the same time there should be any issue.
To Create new FF profile use below code:
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(false);
profile.setAssumeUntrustedCertificateIssuer(true);
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(dc);
The application I'm testing requires a login with the user's Google account. Every time I log in, it displays/requires that I select the 'Allow Access' button as if it doesn't remember that I have already added it to my list of Authorized Access for my Google account. This doesn't happen when I test manually, only when I'm running Selenium. Has anyone come across an issue like this or know of a solution? Thanks in advance.
WebDriver driver = selenium_driver.get(); // using chrome driver
baseUrl = defaults.getProperty("base_url"); // this is set to my localhost
helper.ConnectToURL(baseUrl);
When this started happening, I had been using Selenium 2.28.0--since then, I've updated to 2.31.0 but it's exhibiting the same behavior.
Disclaimer: This is currently not possible according to the ChromeDriver wiki. It states in the "Known Issues" section "Cannot specify a custom profile". (https://code.google.com/p/selenium/wiki/ChromeDriver)
At some point when it is fixed, I would suggest creating or using the default chrome profile that has your authorized access set that your test uses whenever it starts up.
According to the ChromeDriver wiki: "By default, ChromeDriver will create a new temporary profile for each session".
Checkout this post for more in depth information regarding capabilities: http://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches
I do my work in .NET and Windows; my set up would look something like this:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("start-maximized");
chromeOptions.AddArgument("user-data-dir=C:\\Users\\username\\AppData\\Local\\Google\\Chrome\\User Data\\Default");
capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability(ChromeOptions.Capability, chromeOptions);
ChromeDriver chromeDriver= new ChromeDriver(this.Environment.ChromeDriverLocation, chromeOptions);
If you are not limited to using Chrome for your tests you are able to create and use custom profiles using Firefox.