Я искал все недавно заданные вопросы, но не нашел ответа. У меня вопрос, я не понимаю, почему я продолжаю получать ошибку ниже, когда использую Chromederiver, а не firefox. Мой код запускает браузер и выдает эту ошибку при попытке отправить ключ в поле имени пользователя. Пожалуйста, помогите мне. Заранее спасибо. Ниже мой код:
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: 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();
}
}
Класс шагов:
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");
}
}
Класс настройки:
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:
<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 -->
Ошибка:
[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]
Буду признателен за любую помощь, пожалуйста. "запускаются экземпляры драйвера chrome вместо одного файла свойств
serenity
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