I am using this code,
new WebDriverTestBase().getDriver().get("http://www.google.com/");
But this doesn't launch the chrome in full screen. How to maximize the chrome window in QAF?
To maximize web window,
getDriver().manage().window().maximize();
or
getDriver().manage().window().fullscreen();
or
getDriver().manage().window().setSize(new Dimension(width, height));
For chrome you can try using chromeOptions capability
chrome.additional.capabilities={"chromeOptions":{"args":["--start-maximized"]}}
Above solution is chrome browser specific. In order for solution to work with different browsers, you also can implement driver listener and maximize window on driver initialize. For example, your listener method can look like below:
package com.sample;
....
public class WindowMaximizeListener extends QAFWebDriverCommandAdapter {
#Override
public void onInitialize(QAFExtendedWebDriver driver){
//write code to maximize browser window
driver.manage().window().maximize();
}
}
Register listener using qaf.listeners property.
qaf.listeners=com.sample.WindowMaximizeListener
Above listener will maximize browser window as and when new browser session created.
Related
I am working on Desktop application using WinAppDriver and Selenium C#.
There are couple of links on the application.
If we click on the link, it will redirect to default browser.
How I can switch focus from WinAppDriver to IWebDriver ?
How to verify the link, whether the link opened in default browser or not?
Please help on this. Thank you.
// Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
// Perform the actions on new window
// Close the new window, if that window no more required
driver.close();
// Switch back to original browser (first window)
driver.switchTo().window(winHandleBefore);
I want to open chrome browser console by pressing keyboard keys Ctrl+Shift+j in selenium webdriver.
I am able to do this action using Robot class but I want this without Robot class. I have used the Actions class and Keys class using sendKeys. But I am unable to open browser console.
Is it chrome browser version issue or OS? Why the browser console is not opening using Action class and Keys class. ?
To open chrome browser console you can use the ChromeOptions class with --auto-open-devtools-for-tabs argument as follows:
Test Configuration:
Selenium: Selenium Standalone Server v3.14.0
ChromeDriver: ChromeDriver 2.46.628402
Chrome: Google Chrome 72.0.3626.96
Code Block:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class A_Chrome_Browser_Console {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("--disable-extensions");
options.addArguments("--auto-open-devtools-for-tabs");
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
System.out.println(driver.getTitle());
}
}
Console Output:
Google
Browser Console Snapshot:
You can find a relevant python based discussion in Opening inspect (pressing F12) on Chrome via Selenium
I am facing an weird issue. I have a selenium suite to execute on multiple browsers. It works fine of chrome and Firefox. But in case of IE, the web page under test gets shrunk (web page resize) making elements hidden. Hence facing NoSuchElementException.
I have already tried executing on full screen. No help.
Please help in solving this issue.
Thanks,
Praveen
Don't know the exact reason for that, however, suggested workaround would be to implement pre-execution method for your test which would take care of all your browser different configurations. For example, if you are using Java with Selenium and JUnit5, it might be:
#BeforeEach
void beforeTestExecution() {
DesiredCapabilities desiredCapabilities = DesiredCapabilities.internetExplorer();
desiredCapabilities.setCapability(
CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
driver = new InternetExplorerDriver(desiredCapabilities);
// Navigate to URL
driver.get("http://www.yoursite.com");
// Maximize your website window before test.
driver.manage().window().maximize();
}
Or:
#BeforeEach
void configBrowser() {
DesiredCapabilities desiredCapabilities = DesiredCapabilities.internetExplorer();
desiredCapabilities.setCapability(
CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
driver = new InternetExplorerDriver(desiredCapabilities);
// Start Internet Explorer maximized.
driver.manage().window().maximize();
}
I am Not able to close the Internet Explorer via selenium script, I tried every Solution to Kill the IEDriver task and Iexplorer.exe.
I also Tried solution: Internet Explorer 11 does not close after Selenium Test 2 but it still not working for me.
I am Using below,
Selenium 3.4,
IE: 11.1358.14393.0,
InternetExplorerServerDriver: 3.4.0
Below is my code.
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Tc03_IEDriver_First_use {
public static void main(String[] args) throws Exception {
//Set IEDriver Properties
System.setProperty("webdriver.ie.driver", "D:\\Rohit Bhatkar\\Selenium Jars\\IEDriverServer_x64_3.4.0\\IEDriverServer.exe");
//Set desired Capabilities of IE. these statements removes an zoomsetting error.
//You Can set Zoom mannually as, Go To View Menu on IE > Click On Zoom > Select 100%
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
//Create IEDriver obj, Open Browser, Open URL, Close the Browser
WebDriver obj1= new InternetExplorerDriver(caps);
obj1.manage().window().maximize();
obj1.get("https://www.google.com");
obj1.quit(); //IE not Closing. Steel need to do some work to close the browser
}
}
I would try to first obj1.close() to close the browser window. Then I would use obj1.quit() to quit the webdriver which would close it's terminal window in Windows.
Your code seems to work fine. I tested it and the IE browser closed at the end.
Try obj1.close(); instead of obj1.quit();
Here is the Answer to your Question:
Try these settings for IE 11:
Note: You have to set Zoom Level to 100% for IE to work properly.
System.setProperty("webdriver.ie.driver", "C:\\Utility\\BrowserDrivers\\IEDriverServer.exe");
DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
cap.setCapability("platform", "WIN8");
cap.setCapability("version", "11");
cap.setCapability("browserName", "internet explorer");
cap.setCapability("ignoreProtectedModeSettings",1);
cap.setCapability("nativeEvents","false");
cap.setCapability("ignoreZoomSetting", true);
cap.setCapability("requireWindowFocus","true");
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
WebDriver driver = new InternetExplorerDriver(cap);
driver.manage().window().maximize();
driver.get("https://google.co.in");
System.out.println(driver.getTitle());
driver.quit();
Let me know if this Answers your Question.
We've got some good selenium tests running against Firefox with Play 2.1
http://www.playframework.com/documentation/api/2.0/scala/play/api/test/Helpers
However even though webdriver does support Internet Explorer, i dont see an IE helper. Is there any way around this?
Based on the Fluentlenium documentation, your test class should extend FluentTest. You can then simply override the getDefaultDriver() method to change the browser:
public class IntegrationTest extends FluentTest {
#Override
public WebDriver getDefaultDriver(){
return new InternetExplorerDriver();
}
}
You should be able to return any Selenium WebDriver in this method (only tested with IE and FF).