I am using selenium to autofill the form fields through internet explorer.But what is happening it is taking to long to fill the required fields. Is there any way by which we can increase the speed.
Here is the code:
System.setProperty("webdriver.ie.driver","C:\\Users\\mayank\\Desktop\\IEDriverServer.exe");
WebDriver driver=new InternetExplorerDriver();
driver.get("http://online.newindia.co.in");
driver.findElement(By.name("loginid")).sendKeys("abc");
driver.findElement(By.name("password")).sendKeys("xyz");
driver.findElement(By.id("login")).click();
DesiredCapabilities ieCaps = DesiredCapabilities.internetExplorer();
ieCaps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
ieCaps.setCapability("requireWindowFocus", true);
driver = new InternetExplorerDriver(ieCaps);
add these four lines
Related
I want to get the total number of request on network for specific url. how can I do it using selenium or selenide.
There is a search bar on my webpage and if I start typing in the search box it will show the auto complete result and on every character typed there is a request made. I want to check that how many time request is made.
Can someone please help in this regard or any hint if it is possible using selenium webdriver?
Yes, you can do that using JavascriptExecutor.
Code is as below:
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
driver.get("http://www.google.com");
String scriptToExecute = "var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; var network = performance.getEntries() || {}; return network;";
String netData = ((JavascriptExecutor)driver).executeScript(scriptToExecute).toString();
System.out.println(netData);
The first code return network return network;" because of this JS tag. You can remove JS code of entity which you don't require.
I am trying to get IE to start each session clean when intializing a remote driver via the Selenium grid. This
DesiredCapabilities caps = null;
caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
WebDriver driver = new RemoteWebDriver(new URL("http://10.10.22.126:5555/wd/hub"), caps);
is not working, IE is starting each new test with the cookies from the previous test, which causes issues. I am trying to implement this
InternetExplorerOptions ieOptions = new InternetExplorerOptions()
.destructivelyEnsureCleanSession();
As dictated here, but I can't figure out how to use this as a remote driver instead of locally. Thanks!
You can set the option as a capability in somewhat this manner:
InternetExplorerOptions ieOptions = new InternetExplorerOptions()
.destructivelyEnsureCleanSession();
capabilities.setCapability("se:ieOptions", ieOptions);
The InternetExplorerOptions class defines the constant for this capability as:
private final static String IE_OPTIONS = "se:ieOptions";
I am trying to navigate to www.google.com and send some inputs to search box using Selenium webdriver with Internet Explorer(IE).
static WebDriver webDriver = null;
static DesiredCapabilities IEDesiredCapabilities = DesiredCapabilities.internetExplorer();
System.setProperty("webdriver.chrome.driver", TestConstants.chromeDriverFilePath);
System.setProperty("webdriver.ie.driver", TestConstants.IEDriverFilePth);
IEDesiredCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true);
webDriver = new InternetExplorerDriver(IEDesiredCapabilities);
//webDriver = new ChromeDriver();
webDriver.navigate().to("http://www.google.com");
webDriver.findElement(By.name("q")).sendKeys("Venkatesh Kolisetty");
//webDriver.findElement(By.id("lst-ib")).sendKeys("Venkatesh Kolisetty");
This piece of code runs very well when i use Chrome, but throws org.openqa.selenium.NoSuchElementException when IE is used.
This opens required web page in the IE browser which is opened by selenium. The problem is selenium is not able to find any element after page is loaded only when IE is used. For chrome, it finds required elements.
Is there any capability to be added in IEDesiredCapabilities
Kindly see the possibility of providing a programmatic solution instead of changing internet options manually.
Yes this is common issue when you use IE.
Open regedit.exe
Open HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
So Zones will contain 0,1,2,3,4 and on right hand side three columns will be visible as soon as you click on 0 i.e. Name Type Data
Now in Name column look for 2500 Double click it. Put Value data as 3 and Base as Hexadecimal
You did this for 0.
Now repeat the same steps for 1,2,3,4..
Do this for all i.e. 0,1,2,3,4,5 => Change all 2500's value data to 3.
After that run this code.
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.ie.driver", "D:\\Selenium\\CP-SAT\\IEDriver\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("www.google.com");
It will run on IE. You need a IEDriverServer.exe as i have shown in path, which will run your IE browser.
Reply to me for further query. I ran the above code in eclipse and it ran successfully.
Happy learning :-)
Issue resolved after adding some required capabilities.
IEDesiredCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
IEDesiredCapabilities.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "http://www.google.com");
IEDesiredCapabilities.internetExplorer().setCapability("ignoreProtectedModeSettings", true);
IEDesiredCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
IEDesiredCapabilities.setJavascriptEnabled(true);
//IEDesiredCapabilities.setCapability("requireWindowFocus", true);
IEDesiredCapabilities.setCapability("enablePersistentHover", false);
IEDesiredCapabilities.setCapability("requireWindowFocus", true); is optional
I am doing a project and I am testing everything in a program like Skype. Through this program, we can do internet calls. I can't test whether two different accounts can call or not at the same time. I am using Selenium. Can anyone help me?
Just create two instances of WebDriver:
WebDriver driver1 = new FirefoxDriver();
driver1.get("http://your-application");
WebDriver driver2 = new FirefoxDriver();
driver2.get("http://your-application");
// login with driver1 and driver2
How can I click accept/dismiss unhandledalerts with WebDriver?
Is it possible to check where the unhandled alerts are coming?
How can I use UNEXPECTED_ALERT_BEHAVIOUR capability? It is not working as I expected?
I've tried like this
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, "Accept");
Try this code:
WebDriver driver;
#BeforeClass
public void setUp() {
DesiredCapabilities dc=new DesiredCapabilities();
dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.ACCEPT);
driver =new FirefoxDriver(dc);
}
I hope this would be helpful to you.
Open Firefox and try 'about:config'.
Findout which Preference Name can solve you problem and set values accordingly using below code. example: I am disabling automatic update of Firefox.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("app.update.enabled", false);
WebDriver driver = new FirefoxDriver(profile);