I have a test case with following scenario:
- Click on global Order Mgmt Super user
- Click on Sales Order link
- Which Actually Opens new Window & Closes automatically
- Focus came back to Parent window & Open up a window popup
- Click on Ok button
Code :
// Click on Global Order MGMT Superuser role & Sales Order
driver.findElement(By.xpath("//a[contains(text(),'Global Order Management Super User')]")).click();
driver.findElement(By.xpath("//*[@id=\"N104\"]")).click();
Set <String> handles =driver.getWindowHandles();
Iterator<String> it = handles.iterator();
String parent = it.next();
String child = it.next();
driver.switchTo().defaultContent();
Alert alert = driver.switchTo().alert();
alert.accept();
Error :
FAILED: testCase1
org.openqa.selenium.NoAlertPresentException:
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: 'ADONGAR-LAP', ip: '10.180.179.18', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 64.0, capabilities: {desiredCapabilities: {acceptInsecureCerts: true, browserName: firefox}}, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 23748, moz:profile: C:\Users\adongar\AppData\Lo..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 7e3fd1a5-32e0-4fb5-b83c-5f46f14ee28a
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createEx