Loading
Inhalt
Filter auswählen

          Keine Ergebnisse
          Keine Ergebnisse
          Hier sind einige Suchtipps

          Überprüfen Sie die Schreibweise Ihrer Stichwörter.
          Verwenden Sie allgemeinere Suchbegriffe.
          Wählen Sie weniger Filter aus, um Ihre Suche auszuweiten.

          Gesamte Salesforce-Hilfe durchsuchen
          Beispiel-OmniScript-Test (Java)

          Beispiel-OmniScript-Test (Java)

          In diesem Beispiel wird die vollständige durchgängige Benutzer-Journey gezeigt, einschließlich Setup, Navigation, Interaktion und Behauptung in zwei Schritten.

          Beispiel
          Beispiel
          package utam.examples.salesforce.web;
          
          import java.net.URLEncoder;
          import java.nio.charset.StandardCharsets;
          import org.testng.Assert;
          import org.testng.annotations.AfterTest;
          import org.testng.annotations.BeforeTest;
          import org.testng.annotations.Test;
          import utam.utils.salesforce.TestEnvironment;
          import utam.omnistudio.core.pageobjects.Omniscript;
          import utam.omnistudio.omniscript.pageobjects.OmniscriptDate;
          import utam.omnistudio.omniscript.pageobjects.OmniscriptPassword;
          import utam.omnistudio.omniscript.pageobjects.OmniscriptRemoteAction;
          import utam.omnistudio.omniscript.pageobjects.OmniscriptStep;
          import utam.omnistudio.omniscript.pageobjects.OmniscriptText;
          
          public class OmniscriptsTests extends SalesforceWebTestBase {
          
            private final TestEnvironment testEnvironment = getTestEnvironment("sandbox44");
          
            @BeforeTest
            public void setup() {
              setupChrome();
              login(testEnvironment, "home");
            }
          
            protected String createOmniscriptAppUrl(String type, String subType, String language, String theme) {
              String baseOrigin = extractOrigin(testEnvironment.getRedirectUrl());
              if (baseOrigin == null || baseOrigin.isEmpty()) {
                String currentUrl = getDomDocument().getUrl();
                baseOrigin = extractOrigin(currentUrl);
              }
              String query = "lightning/page/omnistudio/omniscript"
                  + "?omniscript__type=" + urlEncode(type)
                  + "&omniscript__subType=" + urlEncode(subType)
                  + "&omniscript__language=" + urlEncode(language)
                  + "&omniscript__theme=" + urlEncode(theme)
                  + "&omniscript__tabIcon=custom%3Acustom18"
                  + "&omniscript__tabLabel=a";
              return baseOrigin + query;
            }
          
            private static String extractOrigin(String urlStr) {
              try {
                if (urlStr == null || urlStr.isEmpty()) return null;
                java.net.URL url = new java.net.URL(urlStr);
                String portPart = url.getPort() == -1 ? "" : (":" + url.getPort());
                return url.getProtocol() + "://" + url.getHost() + portPart + "/";
              } catch (Exception e) {
                return null;
              }
            }
          
            private static String urlEncode(String value) {
              return URLEncoder.encode(value == null ? "" : value, StandardCharsets.UTF_8);
            }
          
            protected void navigateToPage(String url) {
              log("Navigate to URL: " + url);
              getDriver().get(url);
            }
          
            protected Omniscript getOmniscript() {
              return from(Omniscript.class);
            }
          
            protected Omniscript goDirectlyToOmniscript(
                String type, String subType, String language, String theme) {
              try {
                log("Navigate to Omniscript App URL: " + createOmniscriptAppUrl(type, subType, language, theme));
                navigateToPage(createOmniscriptAppUrl(type, subType, language, theme));
                return getOmniscript();
              } catch (Exception error) {
                throw new TestInfrastructureException("Could Not Load Omniscript: " + error.getMessage(), error);
              }
            }
          
            @Test
            public void testNavigateToOmniscript() throws InterruptedException {
              // Example values; update to valid Omniscript in the target org
              Omniscript omniscript = goDirectlyToOmniscript("OmniScript", "Test", "English", "lightning");
              omniscript.load();
              omniscript.waitForVisible();
          
              OmniscriptStep step1 = omniscript.getSteps().get(0);
              step1.waitForVisible();
          
              OmniscriptText username = step1.getElementWithName("Username", OmniscriptText.class);
              OmniscriptPassword password = step1.getElementWithName("Password", OmniscriptPassword.class);
              
              username.setValue("omnistudio");
              password.setValue("omniscripts");
          
              Assert.assertEquals(username.getValue(), "omnistudio", "The value of Username is not correct");
              Assert.assertEquals(password.getValue(), "omniscripts", "The value of Password is not correct");
          
              omniscript.getNextButton().click();
          
              OmniscriptStep step2 = omniscript.getSteps().get(1);
              step2.waitForVisible();
          
              OmniscriptDate dateOfBirth = step2.getElementWithName("DateOfBirth", OmniscriptDate.class);
              dateOfBirth.setValue("01-01-1990");
              Assert.assertEquals(dateOfBirth.getValue(), "01-01-1990", "The value of DateOfBirth is not correct");
          
              OmniscriptRemoteAction submit = step2.getElementWithName("Submit", OmniscriptRemoteAction.class);
              submit.invokeAction();
            }
          
            @AfterTest
            public final void tearDown() {
              quitDriver();
            }
          
            public static class TestInfrastructureException extends RuntimeException {
              public TestInfrastructureException(String message, Throwable cause) {
                super(message, cause);
              }
            }
          }
           
          Laden
          Salesforce Help | Article