ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Control not passes to the main window when Message popup appears on the screen #979

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Issue Description:

When any Message popup such as Notify or imformation popup appears on the 
screen, and when we close the message popup, the objects are not identified in 
the main window.

Note : Test will pass when running in Firefox

Test Site : www.vitacost.com

Steps to reproduce:

1. Launch the above website and wait for page load to complete.
2. Welcome to vitacost.com popup appears on the screen.
3. Close the popup and click the home page icon. 

Chrome Driver : 2.12
Selenium : 2.42

Code to reproduce the issue

package vitacostTest;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class ChromeTest {

    public static WebDriver driver;

    @BeforeTest
    public void launchApplication(){

        System.setProperty("webdriver.chrome.driver", "properties/chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.manage().deleteAllCookies();
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        driver.get("http://www.vitacost.com");
    }

    @Test
    public void mainTest() throws InterruptedException{
        //Sleep is provided intentionally to show the popup. If wait is not provided sometimes, the popup wont appear on time.
        Thread.sleep(8000);
        checkAndCloseCustomerPopup();
        clickHomeIcon();
    }

    @AfterTest
    public void closeApp(){
        driver.close();
        driver.quit();
    }

    public <T> boolean waitForElement(WebElement oElement,Class<T> clsExpectedPage,boolean bExpectedExists, int iWaitSeconds )
    {
        boolean bExists=false;
        long dtEndTime=System.currentTimeMillis()+ (iWaitSeconds * 1000);       
        do 
        {
            if (isElementDisplayed(oElement) && ExpectedConditions.visibilityOf(oElement)!=null 
                    && (!oElement.getAttribute("style").contains("display:none") && !oElement.getAttribute("style").contains("display: none"))) 
                bExists=true;                   
        }while (bExists!=bExpectedExists && System.currentTimeMillis()<dtEndTime);

        return bExists;
    }

    public boolean isElementDisplayed(WebElement oElement) {
        try
        {
            oElement.isDisplayed();
            return true;
        }
        catch(NoSuchElementException e)
        {
            return false;
        }

    }

    public void checkAndCloseCustomerPopup(){
        if(waitForElement(driver.findElement(By.xpath("//div[contains(@id,'vcMsgBoxPopvcMsgBox')]//img[@src='/images/vcMsgBxCBtn.png']")),ChromeTest.class,true,10))
            try{
                driver.findElement(By.xpath("//div[contains(@id,'vcMsgBoxPopvcMsgBox')]//img[@src='/images/vcMsgBxCBtn.png']")).click();
            }
        catch (Exception Ex)
        {
            System.out.println("No Customer Popup present");
        }
    }

    public void clickHomeIcon(){
        WaitForElementToClick(driver.findElement(By.xpath("//div[@id='Header' or @class='coHdrLogo']/a[contains(@id,'Logo') or contains(@id,'B_TopNavCheckout_LogoTagLine')]")));
        driver.findElement(By.xpath("//div[@id='Header' or @class='coHdrLogo']/a[contains(@id,'Logo') or contains(@id,'B_TopNavCheckout_LogoTagLine')]")).click();
    }

    public void WaitForElementToClick(WebElement oWebElement)
    {
    WebDriverWait oWebDriverWait = new WebDriverWait(driver, 240);
    oWebDriverWait.until(ExpectedConditions.elementToBeClickable(oWebElement));
    }

}

Exception :

org.openqa.selenium.WebDriverException: unknown error: Element is not clickable 
at point (341, 47). Other element would receive the click: <div style="width: 
100%; height: 100%; position: fixed; top: 0px; left: 0px; opacity: 0.5; 
background-color: rgb(0, 0, 0);"></div>
  (Session info: chrome=39.0.2171.65)
  (Driver info: chromedriver=2.12.301325 (962dea43ddd90e7e4224a03fa3c36a421281abb7),platform=Windows NT 6.1 SP1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 77 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'LT-PC-416', ip: '10.1.72.115', os.name: 'Windows 7', 
os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_22'
Session ID: 06243b572d3cde7fc4fb27f6341c9d25
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, 
browserName=chrome, 
chrome={userDataDir=C:\Users\RAMKUM~1\AppData\Local\Temp\scoped_dir1944_26799}, 
rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, 
version=39.0.2171.65, takesHeapSnapshot=true, cssSelectorsEnabled=true, 
databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, 
nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, 
takesScreenshot=true}]
    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.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
    at vitacostTest.ChromeTest.clickHomeIcon(ChromeTest.java:84)
    at vitacostTest.ChromeTest.mainTest(ChromeTest.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Original issue reported on code.google.com by rams...@gmail.com on 25 Nov 2014 at 7:04

GoogleCodeExporter commented 9 years ago

Original comment by andrewch...@chromium.org on 25 Nov 2014 at 6:23

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:19

GoogleCodeExporter commented 9 years ago

Original comment by andrewch...@chromium.org on 12 Mar 2015 at 5:45