Be more graceful for timeouts while Selenium 76/99976/3
authorIttay Stern <ittay.stern@att.com>
Thu, 2 Jan 2020 10:00:56 +0000 (12:00 +0200)
committerIttay Stern <ittay.stern@att.com>
Thu, 2 Jan 2020 13:32:49 +0000 (15:32 +0200)
Issue-ID: VID-647

Change-Id: I0137af588d01b8cad7a9d26ac9789d1685ad0c02
Signed-off-by: Ittay Stern <ittay.stern@att.com>
vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/GeneralUIUtils.java
vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java
vid-automation/src/main/java/vid/automation/test/sections/deploy/DeployModernUIBase.java
vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java
vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java

index c2c93e7..dd632d2 100644 (file)
@@ -642,13 +642,14 @@ public final class GeneralUIUtils {
     public static void waitForAngular2(){
        WebDriverWait wait = newWait(90);
        wait.until(AdditionalConditions.pageLoadWait());
+               waitForLoader(60);
        try {
-                       WebDriverWait briefWait = newWait(2);
+                       WebDriverWait briefWait = newWait(3);
                        briefWait.until(AdditionalConditions.angular2HasFinishedProcessing());
                } catch (TimeoutException | org.openqa.selenium.ScriptTimeoutException e) {
                        logger.info("Ignoring TimeoutException while waiting for angular2: {}", e, e);
+                       waitForLoader(30);
                }
-               waitForLoader(10);
     }
 
        public static Object getAllElementAttributes(WebElement element) {
@@ -826,4 +827,14 @@ public final class GeneralUIUtils {
                ultimateWait();
        }
 
+       public static void acceptDeadObjectException(Runnable todo) {
+               try {
+                       todo.run();
+               } catch (org.openqa.selenium.WebDriverException e) {
+                       if (!e.getMessage().startsWith("TypeError: can't access dead object")) {
+                               throw e;
+                       }
+               }
+       }
+
 }
index 43dd68f..0312208 100644 (file)
@@ -1,16 +1,10 @@
 package vid.automation.test.sections;
 
-import com.aventstack.extentreports.Status;
-import org.junit.Assert;
-import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions;
-import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
-import org.openqa.selenium.*;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-import vid.automation.test.Constants;
-import vid.automation.test.Constants.ViewEdit;
-import vid.automation.test.infra.*;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.onap.sdc.ci.tests.utilities.GeneralUIUtils.getDriver;
 
+import com.aventstack.extentreports.Status;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -19,12 +13,25 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.function.Function;
-
-import static java.util.stream.Collectors.toMap;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.onap.sdc.ci.tests.utilities.GeneralUIUtils.getDriver;
-import static org.testng.Assert.assertEquals;
+import org.junit.Assert;
+import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions;
+import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.TimeoutException;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import vid.automation.test.Constants;
+import vid.automation.test.Constants.ViewEdit;
+import vid.automation.test.infra.Click;
+import vid.automation.test.infra.Exists;
+import vid.automation.test.infra.Features;
+import vid.automation.test.infra.Get;
+import vid.automation.test.infra.Input;
+import vid.automation.test.infra.SelectOption;
+import vid.automation.test.infra.Wait;
 
 public class VidBasePage {
 
@@ -276,6 +283,7 @@ public class VidBasePage {
         }
         String target = uri.resolve(path).toString();
 
+        goOutFromIframe();
         getDriver().navigate().to(target);
         GeneralUIUtils.ultimateWait();
 
@@ -308,6 +316,7 @@ public class VidBasePage {
     }
 
     public static void goOutFromIframe(){
+        GeneralUIUtils.acceptDeadObjectException(GeneralUIUtils::ultimateWait);
         getDriver().switchTo().defaultContent();
     }
 
index dd605ff..acddc1b 100644 (file)
@@ -28,6 +28,7 @@ public abstract class DeployModernUIBase extends DeployDialogBase {
         GeneralUIUtils.ultimateWait();
         clickCancelButtonByTestID();
         goOutFromIframe();
+        GeneralUIUtils.ultimateWait();
     }
 
     @Override
index 4eb637a..70fe620 100644 (file)
@@ -1,34 +1,37 @@
 package vid.automation.test.test;
 
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_NAME;
+import static org.testng.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import static vid.automation.test.Constants.DrawingBoard.DEPLOY_BUTTON;
+
 import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
 import org.junit.Assert;
+import org.onap.sdc.ci.tests.datatypes.UserCredentials;
+import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames;
 import org.onap.vid.api.AsyncInstantiationBase;
 import org.onap.vid.api.CreateServiceWithFailedVnf;
 import org.onap.vid.api.TestUtils;
-import org.onap.sdc.ci.tests.datatypes.UserCredentials;
-import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebElement;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 import vid.automation.test.Constants;
-import vid.automation.test.infra.*;
+import vid.automation.test.infra.Click;
+import vid.automation.test.infra.FeatureTogglingTest;
+import vid.automation.test.infra.Features;
+import vid.automation.test.infra.Get;
+import vid.automation.test.infra.Wait;
 import vid.automation.test.sections.DrawingBoardPage;
 import vid.automation.test.sections.InstantiationStatusPage;
 import vid.automation.test.sections.SideMenu;
 import vid.automation.test.sections.VidBasePage;
 import vid.automation.test.services.AsyncJobsService;
 
-import java.util.Collections;
-
-import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME;
-import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_NAME;
-import static org.testng.Assert.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static vid.automation.test.Constants.DrawingBoard.DEPLOY_BUTTON;
-
 public class InstantiationStatusTest extends VidBaseTestCase {
 
     private final String serviceModelVersion = "5.1";
@@ -126,6 +129,8 @@ public class InstantiationStatusTest extends VidBaseTestCase {
     }
 
     private void checkFailedAuditInfoOnRetry(String instanceName, String requestId, String message) {
+        GeneralUIUtils.ultimateWait();
+
         WebElement webElement = Get.byTestId("model-item-value-instance_name");
         assertEquals(webElement.getText(), instanceName, "Instance Name must be equal");
 
index 41ede9a..c2733f0 100644 (file)
@@ -190,7 +190,7 @@ public class VidBaseTestCase extends SetupCDTest{
 
     @BeforeSuite(alwaysRun = true)
     public void setSmallDefaultTimeout() throws Exception {
-        getDriver().manage().timeouts().implicitlyWait(250, TimeUnit.MILLISECONDS);
+        getDriver().manage().timeouts().implicitlyWait(500, TimeUnit.MILLISECONDS);
     }
 
     @Override