I have a scenario as below
1. Login to the application
2. click on a button (say Buy)
3. This will take me to a new window opened with a new URL automatically
4. Perform actions in the new window
5. Quit
Kindly please provide the exact code to work on this. I tried with the available code that exists in the website which didnt work for me
You can try on following pattern:-
Webdriver driver = new ChromeDriver();
driver.get("URL of application");
driver.findElement(By.id("username").sendKeys("user1");
driver.findElement(By.id("password").sendKeys("pass1");
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.findElement(By.xPath("xpath of button").click();
//now you can switch to pop-up and accordingly accept or dismiss it
driver.switchTo().alert().accept();
driver.quit();
In case you provide the SO community the URL of application then only complete code can be provided.
Related
I have a situation where I need to open a link incognito window from another url.
I have tried by using action class to perform control shift n key events but it's not working.
Robot class working fine but I'm looking for other alternative.
Actions act = new Actions(driver);
act. KeyDown(Keys.cONTROL);
act.keyDown(Keys.SHIFT);
act.keyDown("n").build(). perform ();
But it's not working
In case you want to open a new window in incognito mode i.e. without cookies you can simply open a regular new Selenium driver new window and the to clear the cookies with the following command:
driver.manage().deleteAllCookies();
I'm working on the secured web application. When I click link within frame, it opened another single window where information to be filled.But when I execute this scenario in selenium, it click the link within frame and system display two windows where window1 shows Blank page with title as "Blank Page- window internet explorer' and window2 shows website security certificate with no title.
When I'm doing manually, it showing single window but during automation, it shows two windows.
Note: Application support only IE10.
script:
System.setProperty("webdriver.ie.driver","./tools/IEDriverServer_32.exe");
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
caps.setCapability("ignoreZoomSetting", true);
WebDriver driver = new InternetExplorerDriver(caps);
driver.get(url);
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
Login the application and next step to click link
driver.findElement(By.xpath(".//table[#id='maintable']//a").click();
Please help me on this.
I encountered the exact same issue in IE 10..The issue appears to be resolved when I am setting "nativeEvents" to true using the DesiredCapabilities Class. You may try the same and let us know if it also works for you. Please find code segments for your reference:
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability("nativeEvents", true);
WebDriver driver = new InternetExplorerDriver(ieCapabilities);
The 2nd Line seems to do the trick.
The below solution worked
Modifying the registry value , TabProcGrowth to 0 solved the issue-
Go to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
TabProcGrowth (right-click) → Modify… → Value data: 0
which version of selenium jar are you using. Try below code...
System.setProperty("webdriver.ie.driver","./tools/IEDriverServer_32.exe"); WebDriver driver = new InternetExplorerDriver();
driver.get(url); driver.navigate().to("javascript:document.getElementById('overridelink').click()");
if this not works.... last option, please Reinstall IE and problme will be fixed.
I'm using IEDriver to test my webapp. My test is written in Java and driver is defined as following:
System.setProperty("webdriver.ie.driver","C:\\Selenium\\IE\\IEDriverServer.exe");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
driver = new InternetExplorerDriver(capabilities);
driver.manage().window().maximize();
I'm facing the problem when the tests simulates F5 after form submission with:
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();
As a result appears IE window saying:
I've tried to skip it by performing
actions.keyDown(Keys.CONTROL).sendKeys(Keys.ENTER).perform();
and
driver.switchTo().alert().accept();
As I've understood, this window is not an alert, so driver can not switch to it.
So is there any way to execute "Retry" in this window?
Java Robot utility can be used to click on the Retry button. Sample code is written below:
Robot robot = new Robot();
robot.keyPress(java.awt.event.KeyEvent.VK_ENTER);
robot.keyRelease(java.awt.event.KeyEvent.VK_ENTER);
Hope it helps!
If you use F5, then the page will refresh items which are modified, considers cache, so you will get warning.
Instead try reloading the entire page something like,
driver.navigate().refresh();
This will load the page without any warning. This post will give you some insights.
Look for Diff b/w F5 and navigate().refresh()
We are testing an application build using Telerik.
A demo of Telerik is available here: http://demos.telerik.com/aspnet-ajax/window/examples/radwindowobject/defaultcs.aspx
Our application is build in a similar way.
In this demo you can see a window with Bing in it. I want to switch to it using WebDriver (Java) to perform actions on objects within it.
I have tried to switchto iframe but WebDriver comes back saying it is not an iframe.
Also tried to get window handles and switchto window but with no luck, it is not treated as a new window. Any suggestions please?
The following code worked for me. I was able to enter text in the bing search field.
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://demos.telerik.com/aspnet-ajax/window/examples/radwindowobject/defaultcs.aspx");
driver.switchTo().frame("RadWindow1");
driver.findElement(By.name("q")).sendKeys("Hello this is my text");
Let me know if this helps you.
I'm using Selenium WebDriver (Java) and am trying to change the URL after WebDriver has logged into a page.
Is there a way to either:
Change the URL of the current window, or
Open a new tab and go to another page.
Thanks!
You didn't share any code so i don't know how is your approach about it, I only share my knowledge about this subject.
1) For your first question i think you know how to open a new page with selenium web driver maybe you can use some wait method and then invoke the driver again.
//open browser
driver = new FirefoxDriver();
//login
driver.get("https://www.google.com/");
//set implicit wait
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//Then invoke method again for your second request(I am not try this code maybe you need to create new driver object)
driver.get("https://www.stackoverflow.com");
2) For your second question this link help you.