问:
Am using chrome driver but i keep getting error: Could not instantiate class org.openqa.selenium.firefox.FirefoxDriver
I have searched all recently asked question but found no answer. My question is I dont understand why i keep getting the error below when am using chromederiver and not firefox. My code launches the browser and throws this error when attempting to sendkey into the username field. Please help me out. Thanks in advance. Below is my code:

I have searched all recently asked question but found no answer. My question is I dont understand why i keep getting the error below when am using chromederiver and not firefox. My code launches the browser and throws this error when attempting to sendkey into the username field. Please help me out. Thanks in advance. Below is my code

Feature file:

Feature: Log User in. I want to log Admin User in

```<code>    @firstTest
    Scenario: Login Admin user
      Given that user launches the browser
      When user enters login details and click login button

    **Step definition class** This is what I have done so far:

    public class login_StepDefinition {

        @Steps
        LoginSteps loginstep;

        @Given("that user launches the browser")
        public void that_user_launches_the_browser() throws IOException {
            loginstep.openBrowser();

        }

        @When("user enters login details and click login button")
        public void user_enters_login_details_and_click_login_button() {
            loginstep.enterLoginCredentials();

        }
    }
</code>```

Steps class:

```<code>public class LoginSteps {

        LoginPage loginpage = new LoginPage();

        @Step
        public void openBrowser() throws IOException{
            SetUp_PageObject.launchURL();
        }

        @Step
        public void enterLoginCredentials(){
            loginpage.enterUserName();
        }
    }

    **Java class extending page Object:**

    public class LoginPage extends PageObject{

        Action action= new Action();

        @FindBy(xpath="//input[@id='user_login']") @CacheLookup   WebElement userName;

        public void enterUserName(){
            //System.out.println("what is this: "+ ReadFile.parseConf_File("USERNAME"));

WebDriverWait wait = new WebDriverWait(SetUp_PageObject.driver, 15);
        WebElement element = wait.until(ExpectedConditions.visibilityOf(userName));
            userName.sendKeys("kate@me.com");
        }
    }
</code>```

SetUp class:

```<code>public class SetUp_PageObject {

        public static WebDriver driver;
        final static Logger log = LoggerFactory.getLogger(SetUp_PageObject.class);
        static boolean verifyFileExist = ReadFile.Verify_Setup_Conf_File_Exist();

        public static void launchURL() throws IOException{

                /*Verify Config file exist*/
                if(verifyFileExist == true){
                    log.info("Config file exist, continue ....");
                    log.info(DetectOS());}
                else {log.info("Config file DOES NOT exist, pause ....");}

                String exepath = "chromedriver.exe";
                System.setProperty("webdriver.chrome.driver", exepath);
                ChromeOptions options = new ChromeOptions();
                options.setPageLoadStrategy(PageLoadStrategy.EAGER);
                driver = new ChromeDriver(options);

                driver.manage().window().maximize();
                driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
                driver.get(ReadFile.parseConf_File("scorebuddy_5.6.11"));

        }
</code>```

POM File:

```<code><project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>

            <groupId>com.xyz.xxx</groupId>
            <artifactId>xxx_Automation_Project</artifactId>
            <version>0.0.1-SNAPSHOT</version>

            <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <serenity.version>2.0.91</serenity.version>
                <serenity.maven.version>2.0.91</serenity.maven.version>
                <serenity.cucumber.version>1.9.50</serenity.cucumber.version>
                <basedir>xxx_Automation_Project</basedir>
                <mysql.version>8.0.19</mysql.version>
                <encoding>UTF-8</encoding>
                <tags></tags>
                <parallel.tests>4</parallel.tests>
                <webdriver.driver>chrome</webdriver.driver>
                <webdriver.chrome.driver>chromedriver.exe</webdriver.chrome.driver>
                <webdriver.base.url>chrome</webdriver.base.url>
            </properties>

            <!-- Automation Developers, people responsible for developing the automation framework -->

            <!-- Environment Settings -->
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray</name>
                    <url>https://jcenter.bintray.com</url>
                </repository>
            </repositories>

            <!-- -->
            <pluginRepositories>
                <pluginRepository>
                    <releases>
                        <updatePolicy>never</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray-plugins</name>
                    <url>https://jcenter.bintray.com</url>
                </pluginRepository>
            </pluginRepositories>

            <!-- DEPENDENCIES -->
            <!-- Most projects depend on others to build and run correctly.,
            Maven downloads and links the dependencies on compilation and other goals that require them.
            As an added bonus, Maven brings in the dependencies of those dependencies (transitive dependencies),
            allowing your list to focus solely on the dependencies your project requires. -->

            <!-- Serenity dependency -->
            <dependencies>
                <dependency>    <!-- Core Serenity dependency -->
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-core</artifactId>
                    <version>${serenity.version}</version>
                    <scope>test</scope>
                </dependency>

                <dependency>    <!-- JUnit Serenity dependency -->
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-junit</artifactId>
                    <version>${serenity.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-screenplay</artifactId>
                    <version>${serenity.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-screenplay-webdriver</artifactId>
                    <version>${serenity.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-cucumber</artifactId>
                    <version>${serenity.cucumber.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>4.13</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.assertj</groupId>
                    <artifactId>assertj-core</artifactId>
                    <version>3.6.2</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-all</artifactId>
                    <version>1.3</version>
                    <scope>test</scope>
                </dependency>

                <!-- https://mvnrepository.com/artifact/net.thucydides/thucydides-core
                <dependency>
                    <groupId>net.thucydides</groupId>
                    <artifactId>thucydides-core</artifactId>
                    <version>0.9.125</version>
                </dependency> -->

                <!-- SELENIUM DEPENDENCY -->
                <dependency>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-java</artifactId>
                    <version>3.141.59</version>
                </dependency>

                <!-- DATABASE -->
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                     <version>${mysql.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-simple</artifactId>
                    <version>1.6.1</version>
                </dependency>

                <!-- This is use to integrate with JIRA, needed for later
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-jira-requirements-provider</artifactId>
                    <version>1.1.3-rc.5</version>
                </dependency> -->
            </dependencies>

            <!-- REPORTING Settings -->
            <!-- REPORTING: Mirrors the build element for reporting purposes,
                 contains the elements that correspond specifically for the site generation phase -->

            <reporting>
                <outputDirectory>${basedir}/target/site</outputDirectory>
                <plugins>
                    <plugin>
                        <artifactId>maven-project-info-reports-plugin</artifactId>
                         <version>2.0.1</version>
                        <reportSets>
                  <reportSet></reportSet>
                </reportSets>
              </plugin>
            </plugins>
          </reporting>

            <!-- The BUILD and REPORTING Settings -->
            <!-- BUILD: Handles things like declaring your project's directory structure and managing plugins -->

            <!-- Surefire is used for executing Junit tests testing which is why we
                can’t get it to run feature files directly -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.22.1</version>
                        <configuration>
                            <skip>true</skip>
                            <!-- This turn off failing build if some test failed - Allow maven execute
                                all tests. -->
                            <!-- Basically, the line below::: If we want Serenity to generate reports
                                even if there's a test failure, add the following to the pom.xml: -->
                            <testFailureIgnore>true</testFailureIgnore>
                        </configuration>
                    </plugin>
                    <plugin>    <!-- The Maven Failsafe plugin -->
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.22.1</version>
                        <configuration>
                            <includes>

                                <!-- For parallel test and test integration test run -->
                                <!-- <include>**/*Test.java</include> <include>**/Test*.java</include>
                                    <include>**/*TestSuite.java</include> <include>**/When*.java</include> -->

                                <include>**/features/**/When*.java</include> <!-- Include only tests in the junit directory -->
                            </includes>
                            <systemPropertyVariables>
                                <!-- Pass the webdriver.driver system property to the tests. -->
                                 <webdriver.driver>${webdriver.driver}</webdriver.driver>
                                <webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
                                <webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
                                <surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
                                <surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
                            </systemPropertyVariables>
                            <parallel>classes</parallel>
                            <threadCount>${parallel.tests}</threadCount>
                            <forkCount>${parallel.tests}</forkCount>
                        </configuration>

                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Used to compile and execute Junit tests -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.0</version>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                        </configuration>
                    </plugin>

                    <!-- The Serenity Maven Plugin -->
                    <!-- Bind the aggregate goal plugin to the post-integration-test phase. -->
                    <!--To have reports aggregated from test results: -->
                    <plugin>
                        <groupId>net.serenity-bdd.maven.plugins</groupId>
                        <artifactId>serenity-maven-plugin</artifactId>
                        <version>${serenity.maven.version}</version>
                        <configuration>
                            <tags>${tags}</tags>
                        </configuration>

                        <dependencies>
                            <dependency>
                                <groupId>net.serenity-bdd</groupId>
                                <artifactId>serenity-core</artifactId>
                                <version>${serenity.version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution> <!-- Generate Reports -->
                                <id>serenity-reports</id>
                                <phase>post-integration-test</phase> <!-- Generate the aggregate reports during the post-integration test phase -->
                                <goals>
                                    <goal>aggregate</goal>  <!-- Call the aggregate goal to generate them -->
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>

        </project>

    <!-- end snippet -->
</code>```

Error:

```<code>[INFO] Scanning for projects...
[INFO]
[INFO] ----------< net.serenity_bdd.samples.junit:junit-quick-start >----------
[INFO] Building Serenity JUnit Quick Start Project 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ junit-quick-start ---
[INFO] Deleting C:\Users\Ola Afere\eclipse-workspace\xyz_Automation_Project\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ junit-quick-start ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ junit-quick-start ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to C:\Users\Ola Afere\eclipse-workspace\xyz_Automation_Project\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ junit-quick-start ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ junit-quick-start ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to C:\Users\Ola Afere\eclipse-workspace\xyz_Automation_Project\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ junit-quick-start ---
[INFO] Surefire report directory: C:\Users\Ola Afere\eclipse-workspace\xyz_Automation_Project\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.xyz.test.TestRunner
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/C:/Users/Ola%20Afere/.m2/repository/com/google/inject/guice/4.2.2/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
1163 [main] INFO net.thucydides.core.steps.ConsoleLoggingListener -

-------------------------------------------------------------------------------------
     _______. _______ .______       _______ .__   __.  __  .___________.____    ____
    /       ||   ____||   _  \     |   ____||  \ |  | |  | |           |\   \  /   /
   |   (----`|  |__   |  |_)  |    |  |__   |   \|  | |  | `---|  |----` \   \/   /
    \   \    |   __|  |      /     |   __|  |  . `  | |  |     |  |       \_    _/
.----)   |   |  |____ |  |\  \----.|  |____ |  |\   | |  |     |  |         |  |
|_______/    |_______|| _| `._____||_______||__| \__| |__|     |__|         |__|

 News and tutorials at http://www.serenity-bdd.info
 Documentation at https://wakaleo.gitbooks.io/the-serenity-book/content/
 Join the Serenity Community on Rocket Chat at https://serenity-bdd.rocket.chat
 Serenity BDD Support and Training at http://serenity-bdd.info/#/trainingandsupport
 Learn Serenity BDD online at http://serenity-dojo.com
-------------------------------------------------------------------------------------

1187 [main] INFO net.thucydides.core.steps.ConsoleLoggingListener - Test Suite Started: Log User in
1227 [main] WARN cucumber.runtime.formatter.SerenityReporter - Could not parse the Gherkin in feature file src/test/resources/features/score/Employees_score.feature: file ignored
1290 [main] INFO net.thucydides.core.steps.ConsoleLoggingListener -
 _____ _____ ____ _____   ____ _____  _    ____ _____ _____ ____
|_   _| ____/ ___|_   _| / ___|_   _|/ \  |  _ \_   _| ____|  _ \
  | | |  _| \___ \ | |   \___ \ | | / _ \ | |_) || | |  _| | | | |
  | | | |___ ___) || |    ___) || |/ ___ \|  _ < | | | |___| |_| |
  |_| |_____|____/ |_|   |____/ |_/_/   \_\_| \_\|_| |_____|____/

TEST STARTED: Login Admin user
-------------------------------------------------------------------(log-user-in;login-admin-user)
2144 [main] INFO com.xyz.setUp.SetUp_PageObject - Config file exist, continue ....
2145 [main] INFO com.xyz.setUp.SetUp_PageObject - This driver is running on WINDOWS System...@Current TIME and DATE: 13:09:53 20/02/2020
Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882}) on port 46544
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Feb 20, 2020 1:09:56 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[1582204198.365][SEVERE]: Timed out receiving message from renderer: 0.100
[1582204198.470][SEVERE]: Timed out receiving message from renderer: 0.100
what is this: 5611@mailinator.com
Feb 20, 2020 1:09:58 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
8028 [main] INFO net.serenitybdd.core.webdriver.driverproviders.ProvideNewDriver - Instantiating driver
8030 [main] INFO net.serenitybdd.core.webdriver.driverproviders.ProvideNewDriver - Driver capabilities: Capabilities {acceptInsecureCerts: false, browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, loggingPrefs: org.openqa.selenium.logging..., platform: ANY, version: }
Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882}) on port 13749
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Feb 20, 2020 1:10:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
23857 [main] ERROR net.thucydides.core.steps.ConsoleLoggingListener -
           __  _____ _____ ____ _____   _____ _    ___ _     _____ ____
  _       / / |_   _| ____/ ___|_   _| |  ___/ \  |_ _| |   | ____|  _ \
 (_)_____| |    | | |  _| \___ \ | |   | |_ / _ \  | || |   |  _| | | | |
  _|_____| |    | | | |___ ___) || |   |  _/ ___ \ | || |___| |___| |_| |
 (_)     | |    |_| |_____|____/ |_|   |_|/_/   \_\___|_____|_____|____/
          \_\

TEST FAILED WITH ERROR: Login Admin user
---------------------------------------------------------------------
23941 [main] ERROR net.thucydides.core.steps.ConsoleLoggingListener - TEST FAILED AT STEP Enter login credentials
23941 [main] ERROR net.thucydides.core.steps.ConsoleLoggingListener - Timed out after 2 seconds. Element not found

Failed scenarios:
src/test/resources/features/Dashboard.feature:5 # Login Admin user

1 Scenarios (1 failed)
3 Steps (1 failed, 1 skipped, 1 passed)
0m22.966s

org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: Proxy element for: LoginPage.Login_Button (tried for 15 second(s) with 500 milliseconds interval)
    at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
    at com.xyz.pages.login.LoginPage.enterUserName(LoginPage.java:39)
    at com.xyz.steps.commons.LoginSteps.enterLoginCredentials(LoginSteps.java:24)
    at com.xyz.steps.commons.LoginSteps$ByteBuddy$S3iOTSqg.enterLoginCredentials$accessor$OBXEWnr0(Unknown Source)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:471)
    at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:451)
    at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:424)
    at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:180)
    at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:167)
    at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:75)
    at com.xyz.steps.commons.LoginSteps$ByteBuddy$S3iOTSqg.enterLoginCredentials(Unknown Source)
    at com.xyz.stepDefinition.commons.login_StepDefinition.user_enters_login_details_and_click_login_button(login_StepDefinition.java:34)
    at ?.user enters login details and click login button(src/test/resources/features/Dashboard.feature:7)
Caused by: org.openqa.selenium.NoSuchElementException: Timed out after 2 seconds. Element not found
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-80UR6M4', ip: '192.168.0.177', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.5'

Results :

Tests in error:
  Login Admin user(Log User in): Expected condition failed: waiting for element to be clickable: Proxy element for: LoginPage.Login_Button (tried for 15 second(s) with 500 milliseconds interval)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  33.947 s
[INFO] Finished at: 2020-02-20T13:10:19Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project junit-quick-start: There are test failures.
[ERROR]
</code>```

I will appreciate any help please. " instances of chrome driver are being launched instead of one serenity property file

```<code>    serenity.project.name=Scorebuddy Automation project

#Driver
#webdriver.driver = provided
#webdriver.provided.type=mydriver
#webdriver.provided.mydriver=chromedriver.exe
#serenity.driver.capabilities=mydriver

webdriver.driver = chrome
#webdriver.chrome.driver =chromedriver.exe

#Chrome Preferences
#chrome_preferences.profile_default_content_settings.popups = 0
#chrome_preferences.pdfjs.disabled=true

#General Capabilities
#chrome.capabilities.acceptSslCerts = true
#chrome.capabilities.handlesAlerts = true
</code>```

答:
Lets do some work around, can you please place the below code above this statement   </p>

```<code>driver = new chromeDriver(options);
</code>```

<p>Here, these below statements are tying to get some preferences using options and that has to be passed chromeDriver as an argument. </p>

```<code>ConcurrentHashMap<String, Object> chromePrefs = new ConcurrentHashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);

/*Chrome Arguments*/
options.setExperimentalOption("prefs", chromePrefs);
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("--test-type");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--no-first-run");
options.addArguments("homepage=about:blank");

/*Desired Capabilities*/
DesiredCapabilities Capabilities = DesiredCapabilities.chrome();
Capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
Capabilities.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "none");
Capabilities.setCapability(ChromeOptions.CAPABILITY, options);
Capabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true);
options.merge(Capabilities);
</code>```

Body:
I have searched all recently asked question but found no answer. My question is I dont understand why i keep getting the error below when am using chromederiver and not firefox. My code launches the browser and throws this error when attempting to sendkey into the username field. Please help me out. Thanks in advance. Below is my code:

I have searched all recently asked question but found no answer. My question is I dont understand why i keep getting the error below when am using chromederiver and not firefox. My code launches the browser and throws this error when attempting to sendkey into the username field. Please help me out. Thanks in advance. Below is my code

Feature file:

Feature: Log User in. I want to log Admin User in

    @firstTest
    Scenario: Login Admin user
      Given that user launches the browser
      When user enters login details and click login button

    **Step definition class** This is what I have done so far:

    public class login_StepDefinition {

        @Steps
        LoginSteps loginstep;

        @Given("that user launches the browser")
        public void that_user_launches_the_browser() throws IOException {
            loginstep.openBrowser();

        }

        @When("user enters login details and click login button")
        public void user_enters_login_details_and_click_login_button() {
            loginstep.enterLoginCredentials();

        }
    }

Steps class:

public class LoginSteps {

        LoginPage loginpage = new LoginPage();

        @Step
        public void openBrowser() throws IOException{
            SetUp_PageObject.launchURL();
        }

        @Step
        public void enterLoginCredentials(){
            loginpage.enterUserName();
        }
    }

    **Java class extending page Object:**

    public class LoginPage extends PageObject{

        Action action= new Action();

        @FindBy(xpath="//input[@id='user_login']") @CacheLookup   WebElement userName;

        public void enterUserName(){
            //System.out.println("what is this: "+ ReadFile.parseConf_File("USERNAME"));

WebDriverWait wait = new WebDriverWait(SetUp_PageObject.driver, 15);
        WebElement element = wait.until(ExpectedConditions.visibilityOf(userName));
            userName.sendKeys("kate@me.com");
        }
    }

SetUp class:

public class SetUp_PageObject {

        public static WebDriver driver;
        final static Logger log = LoggerFactory.getLogger(SetUp_PageObject.class);
        static boolean verifyFileExist = ReadFile.Verify_Setup_Conf_File_Exist();

        public static void launchURL() throws IOException{

                /*Verify Config file exist*/
                if(verifyFileExist == true){
                    log.info("Config file exist, continue ....");
                    log.info(DetectOS());}
                else {log.info("Config file DOES NOT exist, pause ....");}

                String exepath = "chromedriver.exe";
                System.setProperty("webdriver.chrome.driver", exepath);
                ChromeOptions options = new ChromeOptions();
                options.setPageLoadStrategy(PageLoadStrategy.EAGER);
                driver = new ChromeDriver(options);

                driver.manage().window().maximize();
                driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
                driver.get(ReadFile.parseConf_File("scorebuddy_5.6.11"));

        }

POM File:

<project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>

            <groupId>com.xyz.xxx</groupId>
            <artifactId>xxx_Automation_Project</artifactId>
            <version>0.0.1-SNAPSHOT</version>

            <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <serenity.version>2.0.91</serenity.version>
                <serenity.maven.version>2.0.91</serenity.maven.version>
                <serenity.cucumber.version>1.9.50</serenity.cucumber.version>
                <basedir>xxx_Automation_Project</basedir>
                <mysql.version>8.0.19</mysql.version>
                <encoding>UTF-8</encoding>
                <tags></tags>
                <parallel.tests>4</parallel.tests>
                <webdriver.driver>chrome</webdriver.driver>
                <webdriver.chrome.driver>chromedriver.exe</webdriver.chrome.driver>
                <webdriver.base.url>chrome</webdriver.base.url>
            </properties>

            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray</name>
                    <url>https://jcenter.bintray.com</url>
                </repository>
            </repositories>

            <pluginRepositories>
                <pluginRepository>
                    <releases>
                        <updatePolicy>never</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray-plugins</name>
                    <url>https://jcenter.bintray.com</url>
                </pluginRepository>
            </pluginRepositories>

            <dependencies>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-core</artifactId>
                    <version>${serenity.version}</version>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-junit</artifactId>
                    <version>${serenity.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-screenplay</artifactId>
                    <version>${serenity.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-screenplay-webdriver</artifactId>
                    <version>${serenity.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-cucumber</artifactId>
                    <version>${serenity.cucumber.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>4.13</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.assertj</groupId>
                    <artifactId>assertj-core</artifactId>
                    <version>3.6.2</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-all</artifactId>
                    <version>1.3</version>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-java</artifactId>
                    <version>3.141.59</version>
                </dependency>

                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                     <version>${mysql.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-simple</artifactId>
                    <version>1.6.1</version>
                </dependency>

            </dependencies>

            <reporting>
                <outputDirectory>${basedir}/target/site</outputDirectory>
                <plugins>
                    <plugin>
                        <artifactId>maven-project-info-reports-plugin</artifactId>
                         <version>2.0.1</version>
                        <reportSets>
                  <reportSet></reportSet>
                </reportSets>
              </plugin>
            </plugins>
          </reporting>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.22.1</version>
                        <configuration>
                            <skip>true</skip>

                            <testFailureIgnore>true</testFailureIgnore>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.22.1</version>
                        <configuration>
                            <includes>

                                <include>**/features/**/When*.java</include>
                            </includes>
                            <systemPropertyVariables>

                                 <webdriver.driver>${webdriver.driver}</webdriver.driver>
                                <webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
                                <webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
                                <surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
                                <surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
                            </systemPropertyVariables>
                            <parallel>classes</parallel>
                            <threadCount>${parallel.tests}</threadCount>
                            <forkCount>${parallel.tests}</forkCount>
                        </configuration>

                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.0</version>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>net.serenity-bdd.maven.plugins</groupId>
                        <artifactId>serenity-maven-plugin</artifactId>
                        <version>${serenity.maven.version}</version>
                        <configuration>
                            <tags>${tags}</tags>
                        </configuration>

                        <dependencies>
                            <dependency>
                                <groupId>net.serenity-bdd</groupId>
                                <artifactId>serenity-core</artifactId>
                                <version>${serenity.version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>serenity-reports</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>aggregate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>

        </project>

Error:

[INFO] Scanning for projects...
[INFO]
[INFO] ----------< net.serenity_bdd.samples.junit:junit-quick-start >----------
[INFO] Building Serenity JUnit Quick Start Project 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ junit-quick-start ---
[INFO] Deleting C:\Users\Ola Afere\eclipse-workspace\xyz_Automation_Project\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ junit-quick-start ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ junit-quick-start ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to C:\Users\Ola Afere\eclipse-workspace\xyz_Automation_Project\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ junit-quick-start ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ junit-quick-start ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to C:\Users\Ola Afere\eclipse-workspace\xyz_Automation_Project\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ junit-quick-start ---
[INFO] Surefire report directory: C:\Users\Ola Afere\eclipse-workspace\xyz_Automation_Project\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.xyz.test.TestRunner
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/C:/Users/Ola%20Afere/.m2/repository/com/google/inject/guice/4.2.2/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
1163 [main] INFO net.thucydides.core.steps.ConsoleLoggingListener -

-------------------------------------------------------------------------------------
     _______. _______ .______       _______ .__   __.  __  .___________.____    ____
    /       ||   ____||   _  \     |   ____||  \ |  | |  | |           |\   \  /   /
   |   (----`|  |__   |  |_)  |    |  |__   |   \|  | |  | `---|  |----` \   \/   /
    \   \    |   __|  |      /     |   __|  |  . `  | |  |     |  |       \_    _/
.----)   |   |  |____ |  |\  \----.|  |____ |  |\   | |  |     |  |         |  |
|_______/    |_______|| _| `._____||_______||__| \__| |__|     |__|         |__|

 News and tutorials at http://www.serenity-bdd.info
 Documentation at https://wakaleo.gitbooks.io/the-serenity-book/content/
 Join the Serenity Community on Rocket Chat at https://serenity-bdd.rocket.chat
 Serenity BDD Support and Training at http://serenity-bdd.info/#/trainingandsupport
 Learn Serenity BDD online at http://serenity-dojo.com
-------------------------------------------------------------------------------------

1187 [main] INFO net.thucydides.core.steps.ConsoleLoggingListener - Test Suite Started: Log User in
1227 [main] WARN cucumber.runtime.formatter.SerenityReporter - Could not parse the Gherkin in feature file src/test/resources/features/score/Employees_score.feature: file ignored
1290 [main] INFO net.thucydides.core.steps.ConsoleLoggingListener -
 _____ _____ ____ _____   ____ _____  _    ____ _____ _____ ____
|_   _| ____/ ___|_   _| / ___|_   _|/ \  |  _ \_   _| ____|  _ \
  | | |  _| \___ \ | |   \___ \ | | / _ \ | |_) || | |  _| | | | |
  | | | |___ ___) || |    ___) || |/ ___ \|  _ < | | | |___| |_| |
  |_| |_____|____/ |_|   |____/ |_/_/   \_\_| \_\|_| |_____|____/

TEST STARTED: Login Admin user
-------------------------------------------------------------------(log-user-in;login-admin-user)
2144 [main] INFO com.xyz.setUp.SetUp_PageObject - Config file exist, continue ....
2145 [main] INFO com.xyz.setUp.SetUp_PageObject - This driver is running on WINDOWS System...@Current TIME and DATE: 13:09:53 20/02/2020
Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882}) on port 46544
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Feb 20, 2020 1:09:56 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[1582204198.365][SEVERE]: Timed out receiving message from renderer: 0.100
[1582204198.470][SEVERE]: Timed out receiving message from renderer: 0.100
what is this: 5611@mailinator.com
Feb 20, 2020 1:09:58 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
8028 [main] INFO net.serenitybdd.core.webdriver.driverproviders.ProvideNewDriver - Instantiating driver
8030 [main] INFO net.serenitybdd.core.webdriver.driverproviders.ProvideNewDriver - Driver capabilities: Capabilities {acceptInsecureCerts: false, browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, loggingPrefs: org.openqa.selenium.logging..., platform: ANY, version: }
Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882}) on port 13749
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Feb 20, 2020 1:10:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
23857 [main] ERROR net.thucydides.core.steps.ConsoleLoggingListener -
           __  _____ _____ ____ _____   _____ _    ___ _     _____ ____
  _       / / |_   _| ____/ ___|_   _| |  ___/ \  |_ _| |   | ____|  _ \
 (_)_____| |    | | |  _| \___ \ | |   | |_ / _ \  | || |   |  _| | | | |
  _|_____| |    | | | |___ ___) || |   |  _/ ___ \ | || |___| |___| |_| |
 (_)     | |    |_| |_____|____/ |_|   |_|/_/   \_\___|_____|_____|____/
          \_\

TEST FAILED WITH ERROR: Login Admin user
---------------------------------------------------------------------
23941 [main] ERROR net.thucydides.core.steps.ConsoleLoggingListener - TEST FAILED AT STEP Enter login credentials
23941 [main] ERROR net.thucydides.core.steps.ConsoleLoggingListener - Timed out after 2 seconds. Element not found

Failed scenarios:
src/test/resources/features/Dashboard.feature:5 # Login Admin user

1 Scenarios (1 failed)
3 Steps (1 failed, 1 skipped, 1 passed)
0m22.966s

org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: Proxy element for: LoginPage.Login_Button (tried for 15 second(s) with 500 milliseconds interval)
    at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
    at com.xyz.pages.login.LoginPage.enterUserName(LoginPage.java:39)
    at com.xyz.steps.commons.LoginSteps.enterLoginCredentials(LoginSteps.java:24)
    at com.xyz.steps.commons.LoginSteps$ByteBuddy$S3iOTSqg.enterLoginCredentials$accessor$OBXEWnr0(Unknown Source)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:471)
    at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:451)
    at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:424)
    at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:180)
    at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:167)
    at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:75)
    at com.xyz.steps.commons.LoginSteps$ByteBuddy$S3iOTSqg.enterLoginCredentials(Unknown Source)
    at com.xyz.stepDefinition.commons.login_StepDefinition.user_enters_login_details_and_click_login_button(login_StepDefinition.java:34)
    at ?.user enters login details and click login button(src/test/resources/features/Dashboard.feature:7)
Caused by: org.openqa.selenium.NoSuchElementException: Timed out after 2 seconds. Element not found
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-80UR6M4', ip: '192.168.0.177', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.5'

Results :

Tests in error:
  Login Admin user(Log User in): Expected condition failed: waiting for element to be clickable: Proxy element for: LoginPage.Login_Button (tried for 15 second(s) with 500 milliseconds interval)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  33.947 s
[INFO] Finished at: 2020-02-20T13:10:19Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project junit-quick-start: There are test failures.
[ERROR]

I will appreciate any help please. " instances of chrome driver are being launched instead of one serenity property file

    serenity.project.name=Scorebuddy Automation project

#Driver
#webdriver.driver = provided
#webdriver.provided.type=mydriver
#webdriver.provided.mydriver=chromedriver.exe
#serenity.driver.capabilities=mydriver

webdriver.driver = chrome
#webdriver.chrome.driver =chromedriver.exe

#Chrome Preferences
#chrome_preferences.profile_default_content_settings.popups = 0
#chrome_preferences.pdfjs.disabled=true

#General Capabilities
#chrome.capabilities.acceptSslCerts = true
#chrome.capabilities.handlesAlerts = true

Body:
Lets do some work around, can you please place the below code above this statement

driver = new chromeDriver(options);

Here, these below statements are tying to get some preferences using options and that has to be passed chromeDriver as an argument.

ConcurrentHashMap<String, Object> chromePrefs = new ConcurrentHashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);

/*Chrome Arguments*/
options.setExperimentalOption("prefs", chromePrefs);
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("--test-type");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--no-first-run");
options.addArguments("homepage=about:blank");

/*Desired Capabilities*/
DesiredCapabilities Capabilities = DesiredCapabilities.chrome();
Capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
Capabilities.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "none");
Capabilities.setCapability(ChromeOptions.CAPABILITY, options);
Capabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true);
options.merge(Capabilities);


来源: stackexchange

问:
What is this Swift code doing? func somefunc(where: (_: NSLayoutConstraint) -> Bool)
I'm used to Objective-C but not Swift. I understand the very basics of Swift and I tried to read docs and grasp it myself but can't. What confuses me is the function declaration, I don't get what's going on, what arguments (or other function?) it does accept and what it does with where inside. If someone could translate it in terms of Objective-C that'd be great and it'd explain it to me.

```<code>// extension of UIView
    func removeFirstConstraint(where: (_: NSLayoutConstraint) -> Bool) {
         if let constrainIndex = constraints.firstIndex(where: `where`) {
              removeConstraint(constraints[constrainIndex])
         }
    }
</code>```

And this is how it's called in other parts of code (a subclass of UIView):

```<code>trackView.removeFirstConstraint { $0.firstAttribute == widthAttribute }
</code>```

and

```<code>removeFirstConstraint(where: { $0.firstAttribute == oldConstraintAttribute && $0.firstItem === self && $0.secondItem == nil })
</code>```

Which also confuses me because of the difference and the usage of where.

答:
The removeFirstConstraint function argument is what is called a closure, ie. a function.

More on closures here : https://docs.swift.org/swift-book/LanguageGuide/Closures.html .

In your case, the closure must have the signature (_: NSLayoutConstraint) -> Bool, ie. it should take a layoutConstraint as argument and return a boolean.
So, for your case, the removeFirstConstraint function will call the closure on every constraint of the UIView, and remove the first that, when passed as argument to the closure, will return true.

The two calls of the function are equivalent, you can pass a closure as a normal argument for the function,

```<code>trackView.removeFirstConstraint (where: { /*closure code*/ })
</code>```

or simplify this way :

```<code>trackView.removeFirstConstraint { /*closure code*/ }
</code>```

$0 represents the first argument of the closure.
Hence, the code

```<code>trackView.removeFirstConstraint { $0.firstAttribute == widthAttribute }
</code>```

will remove the first constraint whose firstAttribute is equal to widthAttribute.

Oh, and in the code

```<code>func removeFirstConstraint(where: (_: NSLayoutConstraint) -> Bool) {
         if let constrainIndex = constraints.firstIndex(where: `where`) {
              removeConstraint(constraints[constrainIndex])
         }
    }
</code>```

the where closure passed as argument to the removeFirstConstraint function is directly passed to function firstIndex, which also takes a closure as parameter. firstIndex, called on an array, returns the index of the first item that makes the closure return true.

The quotes around where are necessary because where is a swift keyword, so it must be escaped to be used as an identifier.

ContentLicense: CC BY-SA 4.0

Body:
I'm used to Objective-C but not Swift. I understand the very basics of Swift and I tried to read docs and grasp it myself but can't. What confuses me is the function declaration, I don't get what's going on, what arguments (or other function?) it does accept and what it does with where inside. If someone could translate it in terms of Objective-C that'd be great and it'd explain it to me.

// extension of UIView
    func removeFirstConstraint(where: (_: NSLayoutConstraint) -> Bool) {
         if let constrainIndex = constraints.firstIndex(where: `where`) {
              removeConstraint(constraints[constrainIndex])
         }
    }

And this is how it's called in other parts of code (a subclass of UIView):

trackView.removeFirstConstraint { $0.firstAttribute == widthAttribute }

and

removeFirstConstraint(where: { $0.firstAttribute == oldConstraintAttribute && $0.firstItem === self && $0.secondItem == nil })

Which also confuses me because of the difference and the usage of where.

Body:
The removeFirstConstraint function argument is what is called a closure, ie. a function.

More on closures here : https://docs.swift.org/swift-book/LanguageGuide/Closures.html .

In your case, the closure must have the signature (_: NSLayoutConstraint) -> Bool, ie. it should take a layoutConstraint as argument and return a boolean.
So, for your case, the removeFirstConstraint function will call the closure on every constraint of the UIView, and remove the first that, when passed as argument to the closure, will return true.

The two calls of the function are equivalent, you can pass a closure as a normal argument for the function,

trackView.removeFirstConstraint (where: { /*closure code*/ })

or simplify this way :

trackView.removeFirstConstraint { /*closure code*/ }

$0 represents the first argument of the closure.
Hence, the code

trackView.removeFirstConstraint { $0.firstAttribute == widthAttribute }

will remove the first constraint whose firstAttribute is equal to widthAttribute.

Oh, and in the code

func removeFirstConstraint(where: (_: NSLayoutConstraint) -> Bool) {
         if let constrainIndex = constraints.firstIndex(where: `where`) {
              removeConstraint(constraints[constrainIndex])
         }
    }

the where closure passed as argument to the removeFirstConstraint function is directly passed to function firstIndex, which also takes a closure as parameter. firstIndex, called on an array, returns the index of the first item that makes the closure return true.

The quotes around where are necessary because where is a swift keyword, so it must be escaped to be used as an identifier.


问:
In Java8, when will the merge function be triggered in Collectors.toMap?
I want to transform a Hashmap<String,Long> to a Treemap, in order to sort its key by string.length (I can't simply use treemap.addAll because I have may other logic when insert and I want to use java8)

The code is below. But when keys with same length exist in the initial Hashmap, it will trigger the merge function which throws Exception(I intent to do it because there won't be same string in my case). I wonder why the merge function be triggered since the JavaDoc of toMap() says "If the mapped keys contains duplicates (according to Object#equals(Object)), the value mapping function is applied to each equal element, and results are merged using the provided merging function."  I think that in my code the  "mapped keys" should be the entry in hashMap mapped by Entry::getKey but not string.length() in the TreeMap comparator. i.e. "abc" != "def". So it shouldn't trigger the merge. But?? What the hell?

```<code>public class TestToMap {

    public static Map<String, Long> map1 = new HashMap<String, Long>() {
        {
            put("abc", 123L);
            put("def", 456L);
        }
    };

    public static void main(String[] args) {
        Map<String, Long> priceThresholdMap = map1.entrySet().stream()
            .collect(Collectors.toMap(Entry::getKey,
                                      Entry::getValue,
                                      throwingMerger(),
                                      () -> new TreeMap<String, Long>(
                                          (a, b) -> {
                                              return a.length() - b.length();
                                          }))); // this will trigger merge function, why?
        //() -> new TreeMap<String, Long>(Comparator.comparingInt(String::length).thenComparing(String::compareTo))));  // but this won't trigger merge function

    }

    private static <T> BinaryOperator<T> throwingMerger() {
        return (u, v) -> {
            throw new IllegalStateException(String.format("priceThresholdMap has duplicate v1 %s,v2 %s", u, v));
        };
    }
}
</code>```

答:
According to toMap() source code, it create a accumulator which will fold each element from source stream into map.

```<code>Collector<T, ?, M> toMap(Function<? super T, ? extends K> keyMapper,
                                Function<? super T, ? extends U> valueMapper,
                                BinaryOperator<U> mergeFunction,
                                Supplier<M> mapSupplier) {
        BiConsumer<M, T> accumulator
                = (map, element) -> map.merge(keyMapper.apply(element),
                                              valueMapper.apply(element), mergeFunction);
        return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_ID);
    }
</code>```

And in Map.merge() , when get("def") will return the exist oldValue=123, which key is "abc", because by the comparator I give to TreeMap "def" is equal to "abc". And then oldValue!=null calls merge function.

```<code> default V merge(K key, V value,
            BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
        Objects.requireNonNull(remappingFunction);
        Objects.requireNonNull(value);
        V oldValue = get(key);
        V newValue = (oldValue == null) ? value :
                   remappingFunction.apply(oldValue, value); // call the merge function
        if(newValue == null) {
            remove(key);
        } else {
            put(key, newValue);
        }
        return newValue;
    }
</code>```

ref:Collectors toMap duplicate key

Body:
I want to transform a Hashmap<String,Long> to a Treemap, in order to sort its key by string.length (I can't simply use treemap.addAll because I have may other logic when insert and I want to use java8)

The code is below. But when keys with same length exist in the initial Hashmap, it will trigger the merge function which throws Exception(I intent to do it because there won't be same string in my case). I wonder why the merge function be triggered since the JavaDoc of toMap() says "If the mapped keys contains duplicates (according to Object#equals(Object)), the value mapping function is applied to each equal element, and results are merged using the provided merging function."  I think that in my code the  "mapped keys" should be the entry in hashMap mapped by Entry::getKey but not string.length() in the TreeMap comparator. i.e. "abc" != "def". So it shouldn't trigger the merge. But?? What the hell?

public class TestToMap {

    public static Map<String, Long> map1 = new HashMap<String, Long>() {
        {
            put("abc", 123L);
            put("def", 456L);
        }
    };

    public static void main(String[] args) {
        Map<String, Long> priceThresholdMap = map1.entrySet().stream()
            .collect(Collectors.toMap(Entry::getKey,
                                      Entry::getValue,
                                      throwingMerger(),
                                      () -> new TreeMap<String, Long>(
                                          (a, b) -> {
                                              return a.length() - b.length();
                                          }))); // this will trigger merge function, why?
        //() -> new TreeMap<String, Long>(Comparator.comparingInt(String::length).thenComparing(String::compareTo))));  // but this won't trigger merge function

    }

    private static <T> BinaryOperator<T> throwingMerger() {
        return (u, v) -> {
            throw new IllegalStateException(String.format("priceThresholdMap has duplicate v1 %s,v2 %s", u, v));
        };
    }
}

Body:
According to toMap() source code, it create a accumulator which will fold each element from source stream into map.

Collector<T, ?, M> toMap(Function<? super T, ? extends K> keyMapper,
                                Function<? super T, ? extends U> valueMapper,
                                BinaryOperator<U> mergeFunction,
                                Supplier<M> mapSupplier) {
        BiConsumer<M, T> accumulator
                = (map, element) -> map.merge(keyMapper.apply(element),
                                              valueMapper.apply(element), mergeFunction);
        return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_ID);
    }

And in Map.merge() , when get("def") will return the exist oldValue=123, which key is "abc", because by the comparator I give to TreeMap "def" is equal to "abc". And then oldValue!=null calls merge function.

 default V merge(K key, V value,
            BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
        Objects.requireNonNull(remappingFunction);
        Objects.requireNonNull(value);
        V oldValue = get(key);
        V newValue = (oldValue == null) ? value :
                   remappingFunction.apply(oldValue, value); // call the merge function
        if(newValue == null) {
            remove(key);
        } else {
            put(key, newValue);
        }
        return newValue;
    }

ref:Collectors toMap duplicate key


问:
Laravel 5.8 - How to give permission to users to read,create,update,delete?
How to define permission in controller,to access the function
For example, USER -> Joe can use the function read create update delete
,but USER -> dog can use the function only read.
In which table permission can increase continuously, and define permission dynamic.

I know roles & permissions spatie but it makes the default table, which I want to use my table.

I have table permission

```<code>________________________________________________________
|   id | APP  | read | create | update | delete | group |
|------+------+------+--------+--------+--------+-------|
|    1 |   aa |   1  |    1   |    1   |   1    | admin |
|    2 |   bb |   1  |    0   |    0   |   0    | user  |
|    3 |   cc |   1  |    1   |    1   |   1    | admin |
|______|______|______|________|________|________|_______|
</code>```

and i have table role

```<code>_______________________
|   id | user | group |
|------+------+-------|
|    1 |  joe | admin |
|    2 |  dog | user  |
|    3 |  cat | admin |
|______|______|_______|
</code>```

答: Perhaps you could look into policies: https://laravel.com/docs/5.8/authorization#generating-policies</p>

Body:
How to define permission in controller,to access the function
For example, USER -> Joe can use the function read create update delete
,but USER -> dog can use the function only read.
In which table permission can increase continuously, and define permission dynamic.

I know roles & permissions spatie but it makes the default table, which I want to use my table.

I have table permission

________________________________________________________
|   id | APP  | read | create | update | delete | group |
|------+------+------+--------+--------+--------+-------|
|    1 |   aa |   1  |    1   |    1   |   1    | admin |
|    2 |   bb |   1  |    0   |    0   |   0    | user  |
|    3 |   cc |   1  |    1   |    1   |   1    | admin |
|______|______|______|________|________|________|_______|

and i have table role

_______________________
|   id | user | group |
|------+------+-------|
|    1 |  joe | admin |
|    2 |  dog | user  |
|    3 |  cat | admin |
|______|______|_______|


问:
formset is valid but form has no attribute cleaned_data!
Ok, so I have a formset that is valid. But gives me a error that that form has no attribute cleaned_data..

Honestly I have absolutely no clue what's happening..

I tried my code on terminal and it returned a empty dictionary.. without errors..

forms:

```<code>class Clinical(forms.Form):
    _names = list(ClinicalForm.objects.values_list('form_id', 'form_name'))
    _names.append(("New", u'Nova entrada'))

    cliform_name = forms.ChoiceField(widget=RadioSelect(), choices=_names, label
         ="", required=True)
</code>```

views:

```<code>ClinicalSet = formset_factory(Clinical, extra=2)

formset2 = ClinicalSet(request.POST)
if formset2.is_valid():
    choice1 = formset2.cleaned_data
    return render_to_response('valid_test.html',
                                {
                                    'formset2': formset2,
                                    'wrongs1': wrongs1,
                                    'choice1': choice1
                                    })
else:
    formset2 = ClinicalSet()
return render_to_response('valid_test.html',
                            {
                                'formset2': formset2,
                                'wrongs1': wrongs1,
                                })
</code>```

template:

```<code><form method="post" action="">
<div>
{{ formset2.management_form }}
    {% for form in formset2.forms %}
        {{ form }}
    {% endfor %}
    <input type="submit" value="save" />
</div>
</code>```

If I comment the line where the cleaned_data is called (choice1), I don't receive any error and I'm able to see the forms..

If I select some options and uncomment this line, it works..

I have a similar formset : both forms in formset need to be selected and this one works..

the form that works is the first formset (linked above). The post parameters:

```<code>form-0-pres_name    1
form-1-pres_name    2
form-INITIAL_FORMS  0
form-TOTAL_FORMS    2
</code>```

the user select one option in each form and he's redirect to another view (this one - formset2).

Any help is more than welcome..

答:
If someone need, here are the modifications I've done in the view:</p>

```<code> ClinicalSet = formset_factory(Clinical, extra=tamanh)

 #size of this list will determine number of forms
 wrongs = iter(wrong)
 formset = ClinicalSet(request.POST)
 dic = {}
 if formset.is_valid():
     if len(request.POST.keys()) == 0:
         return render_to_response('valid.html',
                                        {
                                            'formset': formset,
                                            'wrongs': wrongs })
     else:
         #+ 2 because of TOTAL_FORMS and MAX_NUM_FORMS
         if len(request.POST.keys()) != len(wrongs) + 2:
             msg = "You have to select something in all forms!!"
             return render_to_response('valid.html',
                                            {
                                                'formset': formset,
                                                'wrongs': wrongs,
                                                'msg': msg })
         else:
             for n in range(tamanh):
                 #result post into a dictionary, since cleaned_data doesn't work
                 dic[wrongs.next()] = request.POST['form-' + str(n) + '-cliform_name']
                 return HttpResponseRedirect(reverse('valid2', args=[word]))
    else:
        formset = ClinicalSet()
    return render_to_response('valid.html',
                                {
                                    'formset': formset,
                                    'wrongs': wrongs,
                                    'msg': msg
                                    })
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Ok, so I have a formset that is valid. But gives me a error that that form has no attribute cleaned_data..

Honestly I have absolutely no clue what's happening..

I tried my code on terminal and it returned a empty dictionary.. without errors..

forms:

class Clinical(forms.Form):
    _names = list(ClinicalForm.objects.values_list('form_id', 'form_name'))
    _names.append(("New", u'Nova entrada'))

    cliform_name = forms.ChoiceField(widget=RadioSelect(), choices=_names, label
         ="", required=True)

views:

ClinicalSet = formset_factory(Clinical, extra=2)

formset2 = ClinicalSet(request.POST)
if formset2.is_valid():
    choice1 = formset2.cleaned_data
    return render_to_response('valid_test.html',
                                {
                                    'formset2': formset2,
                                    'wrongs1': wrongs1,
                                    'choice1': choice1
                                    })
else:
    formset2 = ClinicalSet()
return render_to_response('valid_test.html',
                            {
                                'formset2': formset2,
                                'wrongs1': wrongs1,
                                })

template:

<form method="post" action="">

{{ formset2.management_form }}
    {% for form in formset2.forms %}
        {{ form }}
    {% endfor %}
    <input type="submit" value="save" />

If I comment the line where the cleaned_data is called (choice1), I don't receive any error and I'm able to see the forms..

If I select some options and uncomment this line, it works..

I have a similar formset : both forms in formset need to be selected and this one works..

the form that works is the first formset (linked above). The post parameters:

form-0-pres_name    1
form-1-pres_name    2
form-INITIAL_FORMS  0
form-TOTAL_FORMS    2

the user select one option in each form and he's redirect to another view (this one - formset2).

Any help is more than welcome..

Body:
If someone need, here are the modifications I've done in the view:

 ClinicalSet = formset_factory(Clinical, extra=tamanh)

 #size of this list will determine number of forms
 wrongs = iter(wrong)
 formset = ClinicalSet(request.POST)
 dic = {}
 if formset.is_valid():
     if len(request.POST.keys()) == 0:
         return render_to_response('valid.html',
                                        {
                                            'formset': formset,
                                            'wrongs': wrongs })
     else:
         #+ 2 because of TOTAL_FORMS and MAX_NUM_FORMS
         if len(request.POST.keys()) != len(wrongs) + 2:
             msg = "You have to select something in all forms!!"
             return render_to_response('valid.html',
                                            {
                                                'formset': formset,
                                                'wrongs': wrongs,
                                                'msg': msg })
         else:
             for n in range(tamanh):
                 #result post into a dictionary, since cleaned_data doesn't work
                 dic[wrongs.next()] = request.POST['form-' + str(n) + '-cliform_name']
                 return HttpResponseRedirect(reverse('valid2', args=[word]))
    else:
        formset = ClinicalSet()
    return render_to_response('valid.html',
                                {
                                    'formset': formset,
                                    'wrongs': wrongs,
                                    'msg': msg
                                    })


问:
Show Month on Scorecard for the highest revenue based on Date Range Filtered
I was thinking of the formula that I should use to show the Month with the highest revenue based on the filtered date range. Below is the sample data on google sheet.

```<code>Date    Revenue
1/1/2014    $222,080.70
6/1/2014    $227,565.29
7/1/2014    $250,951.29
9/1/2014    $256,936.13
11/1/2014   $248,952.56
12/1/2014   $267,996.00
1/1/2015    $338,808.52
2/1/2015    $284,074.09
</code>```

If the date range will be filtered from January 2014 to December 2014, I want the showcard to present the Month wherein the highest revenue was recorded. In this case, it should show January 2015. Please help me on the right formula I should use in creating field in Google Data Studio. Thanks!

答:
One way it can be achieved is by using a Table and sorting by Revenue (aggregated by Max) in descending order. The headers, pagination, etc can be removed, as well as showing just a single row. This will have the effect of a Scorecard displaying a single date (that's sorted by Max Revenue).

The GIF below goes through the process (Google Data Studio Report):

Body:
I was thinking of the formula that I should use to show the Month with the highest revenue based on the filtered date range. Below is the sample data on google sheet.

Date    Revenue
1/1/2014    $222,080.70
6/1/2014    $227,565.29
7/1/2014    $250,951.29
9/1/2014    $256,936.13
11/1/2014   $248,952.56
12/1/2014   $267,996.00
1/1/2015    $338,808.52
2/1/2015    $284,074.09

If the date range will be filtered from January 2014 to December 2014, I want the showcard to present the Month wherein the highest revenue was recorded. In this case, it should show January 2015. Please help me on the right formula I should use in creating field in Google Data Studio. Thanks!


问:
multiple select field pass ajax data as string
My problem is the quantity value pass as a string not as an array. like ["1,2"], however what I need is [1,2]

    Quantity:
    <select name="quantity[]" id="quantity" class="form-control" multiple>
    </select>

```

<pre class="lang-js prettyprint-override"><code>// get the quantity value:
if (res) {
  $("#quantity").empty();
  $.each(res, function(key, value) {
    $("#quantity").append('<option value="' + key + '">' + value + '</option>');
  });
} else {
  $("#quantity").empty();
}

// pass the quantity value:
var quantity = new Array(); //storing the selected values inside an array
$('#quantity :selected').each(function(i, selected) {
  quantity[i] = $(selected).val();
});

$.ajax({
  type: "POST",
  url: "{{route('localBook.store')}}?quantity[]=" + quantity,
  dataType: 'json',
  data: form_data,
  success: function(res) {}
});
</code>```

答:
I think this happens because you are passing the quantity-array as a url parameter instead of passing it in the http body (as intended in the post request). This is redundant if you want to perform a POST-request.

Edit your request, pass data through the data-field in your ajax request and everything will work fine. :)

```<code>$.ajax({
  type: "POST",
  url: "{{route('localBook.store')}}",
  dataType: 'json',
  data: {
    quantity: this.quantity
  },
  success: function(res) {}
});
</code>```

Cheers,

Niklas

Body:
My problem is the quantity value pass as a string not as an array. like ["1,2"], however what I need is [1,2]

    Quantity:
    <select name="quantity[]" id="quantity" class="form-control" multiple>
    </select>

// get the quantity value:
if (res) {
  $("#quantity").empty();
  $.each(res, function(key, value) {
    $("#quantity").append('<option value="' + key + '">' + value + '</option>');
  });
} else {
  $("#quantity").empty();
}

// pass the quantity value:
var quantity = new Array(); //storing the selected values inside an array
$('#quantity :selected').each(function(i, selected) {
  quantity[i] = $(selected).val();
});

$.ajax({
  type: "POST",
  url: "{{route('localBook.store')}}?quantity[]=" + quantity,
  dataType: 'json',
  data: form_data,
  success: function(res) {}
});

Body:
I think this happens because you are passing the quantity-array as a url parameter instead of passing it in the http body (as intended in the post request). This is redundant if you want to perform a POST-request.

Edit your request, pass data through the data-field in your ajax request and everything will work fine. :)

$.ajax({
  type: "POST",
  url: "{{route('localBook.store')}}",
  dataType: 'json',
  data: {
    quantity: this.quantity
  },
  success: function(res) {}
});

Cheers,

Niklas


问:
Slowness issue with DMZ Jenkins due to active directory integration
I have DMZ Jenkins, where the active Directory login is not working for us. Our network team have noticed that request is being sent to multiple domain controllers servers (which cause us slowness in login- almost 10 minutes). how can we limit it to only one DC server?

Jenkins version: 2.176.1

答: We had to mention the specific DC on the Site field</p>


问:
Stuck at Whitescreen after building Ionic React android app
ionic run android -l --external with this I got to test the app on phone with hot reloading, but when I try to build it on studio it just shows a blank white screen after the capacitor logo.

I am just testing out ionic, just got the tabs template going on to test it out.

here's how I build the apk.
ionic run android -> then on android studio -> build apk

答:
I'm getting a similar problem, using WSL and the Windows Android Studio:

On WSL:

```<code>ionic start photo-gallery tabs --type=react --capacitor
cd photo-gallery/
ionic integrations enable capacitor
npx cap init photo-app com.mike.atkinson

mkdir www
-- create a www/index.html file
npx cap add android
ionic serve                  #check everything runs OK in a browser then ^C
#line below stops a warning in the Windows Android Studio when the App is run.
mkdir node_modules/@capacitor/android/capacitor/build/intermediates/check_manifest_result/debug/checkDebugManifest/out
</code>```

On Windows:

```<code>    Run Android Studio
    Select photo-app
    build it
    Create an Android Virtual Machine - using Pixel XL with Android 10
    Select it
    Run photo-app                                                <-- just a blank screen
    Connect phone (Umidigi A3S  running Android 10)
    Select phone
    Run photo-app                     <-- just shows the splash screen then a blank screen
</code>```

As I am new to Android, it is probably something I'm doing wrong, but as this is an example React app I can't figure out what.

It turns out I made two simple errors:

In capacitor.config.json the webDir should be set to "build"

Ionic serve only does the build for the web service, to build for the android target you need to do:

```<code>npm run build
</code>```

then run the Android Studio on the Windows side.

Body:
I'm getting a similar problem, using WSL and the Windows Android Studio:

On WSL:

ionic start photo-gallery tabs --type=react --capacitor
cd photo-gallery/
ionic integrations enable capacitor
npx cap init photo-app com.mike.atkinson

mkdir www
-- create a www/index.html file
npx cap add android
ionic serve                  #check everything runs OK in a browser then ^C
#line below stops a warning in the Windows Android Studio when the App is run.
mkdir node_modules/@capacitor/android/capacitor/build/intermediates/check_manifest_result/debug/checkDebugManifest/out

On Windows:

    Run Android Studio
    Select photo-app
    build it
    Create an Android Virtual Machine - using Pixel XL with Android 10
    Select it
    Run photo-app                                                <-- just a blank screen
    Connect phone (Umidigi A3S  running Android 10)
    Select phone
    Run photo-app                     <-- just shows the splash screen then a blank screen

As I am new to Android, it is probably something I'm doing wrong, but as this is an example React app I can't figure out what.

It turns out I made two simple errors:

In capacitor.config.json the webDir should be set to "build"

Ionic serve only does the build for the web service, to build for the android target you need to do:

npm run build

then run the Android Studio on the Windows side.


问:
How to access text boxes on a particular slide and change its text in Google Slides?
I am trying to access a text box on Google slides in order to change its text but every time I run the programme, it prints "textRange" on the alert box despite the fact that there's some text in the text box.</p>

```<code>function updateTextBox() {
  var slides = SlidesApp.getActivePresentation().getSlides();
  var shapes = slides[0].getShapes();
  var text = shapes[0].getText();
  SlidesApp.getUi().alert(text);
}
</code>```

答:
You are missing asString()

Indeed,it is documented that the method getText() return a TextRange.

TextRange is a class that has methods, to return the actual test fo the range you need to use the method asString().

var text = shapes[0].getText().asString();

Body:
I am trying to access a text box on Google slides in order to change its text but every time I run the programme, it prints "textRange" on the alert box despite the fact that there's some text in the text box.

function updateTextBox() {
  var slides = SlidesApp.getActivePresentation().getSlides();
  var shapes = slides[0].getShapes();
  var text = shapes[0].getText();
  SlidesApp.getUi().alert(text);
}