Перейти к содержимому

Selenium WebDriver: полное руководство
онлайн, начало 19 октября
Логи как инструмент тестировщика
онлайн, начало 22 октября
Школа для начинающих тестировщиков
онлайн, начало 22 октября
Тестирование REST API
онлайн, начало 22 октября
Фотография

Teamcity + Maven + WebDriver + Java: падают тесты

Teamcity Maven WebDriver ChromeDriver FirefoxDriver Java тесты PHP Git Ubuntu

  • Авторизуйтесь для ответа в теме
В теме одно сообщение

#1 Charisma

Charisma

    Новый участник

  • Members
  • Pip
  • 5 сообщений
  • ФИО:Charisma
  • Город:Москва


Отправлено 30 Октябрь 2014 - 18:11

Добрый вечер. 

Автоматизацией давно не занималась, да снова пришлось вспомнить былое. 

 

Есть:

- автотесты на java в одном репозитарии гита,

- проект на PHP в другом репозитарии гита,

- установленный на машине #1 Teamcity 8.1.5 (build 30240),

- на машине #2 установлены: агент тимсити, ubuntu 12.04, jdk 1.7, maven 3, Xvfb, google chrome и firefox последних стабильных версий. 

 

Тесты локально на windows-машине запускаются, гоняются, выдают отчет в surefire. 

На удаленной машине сначала htmlunitdriver отрабатывает нормально, но как только вызывается хром/фф драйвер - падают с разными ошибками. Часть победила, эти не поддаются, к сожалению. 

 

Часть 1. Chrome

[18:45:35][com.project:tests] Tests run: 246, Failures: 2, Errors: 0, Skipped: 243, Time elapsed: 383.296 sec <<< FAILURE! - in TestSuite
[18:45:35][com.project:tests] beforeMethod(com.blamper.tests.UserPageTests)  Time elapsed: 62.175 sec  <<< FAILURE!
[18:45:35][com.project:tests] org.openqa.selenium.WebDriverException: chrome not reachable
[18:45:35][com.project:tests]   (Driver info: chromedriver=2.12.301324 (de8ab311bc9374d0ade71f7c167bad61848c7c48),platform=Linux 2.6.32-22-pve x86) (WARNING: The server did not provide any stacktrace information)
[18:45:35][com.project:tests] Command duration or timeout: 60.63 seconds
[18:45:35][com.project:tests] Build info: version: '2.43.1', revision: '5163bceef1bc36d43f3dc0b83c88998168a363a0', time: '2014-09-10 09:43:55'
[18:45:35][com.project:tests] System info: host: 'host', ip: '10.10.10.100', os.name: 'Linux', os.arch: 'i386', os.version: '2.6.32-22-pve', java.version: '1.7.0_67'
[18:45:35][com.project:tests] Driver info: org.openqa.selenium.chrome.ChromeDriver
[18:45:35][com.project:tests] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[18:45:35][com.project:tests] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[18:45:35][com.project:tests] 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[18:45:35][com.project:tests] 	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
[18:45:35][com.project:tests] 	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
[18:45:35][com.project:tests] 	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
[18:45:35][com.project:tests] 	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
[18:45:35][com.project:tests] 	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
[18:45:35][com.project:tests] 	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
[18:45:35][com.project:tests] 	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
[18:45:35][com.project:tests] 	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
[18:45:35][com.project:tests] 	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:139)
[18:45:35][com.project:tests] 	at com.blamper.framework.browser.Browser.chromeSSL(Browser.java:89)
[18:45:35][com.project:tests] 	at com.blamper.framework.browser.Browser.getSystemDriver(Browser.java:74)
[18:45:35][com.project:tests] 	at com.blamper.framework.browser.Browser.<init>(Browser.java:43)
[18:45:35][com.project:tests] 	at com.blamper.framework.testcase.TestCase.beforeMethod(TestCase.java:46)
[18:45:35][com.project:tests] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[18:45:35][com.project:tests] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[18:45:35][com.project:tests] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[18:45:35][com.project:tests] 	at java.lang.reflect.Method.invoke(Method.java:606)
[18:45:35][com.project:tests] 	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
[18:45:35][com.project:tests] 	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:543)
[18:45:35][com.project:tests] 	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:212)
[18:45:35][com.project:tests] 	at org.testng.internal.Invoker.invokeMethod(Invoker.java:631)
[18:45:35][com.project:tests] 	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
[18:45:35][com.project:tests] 	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
[18:45:35][com.project:tests] 	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
[18:45:35][com.project:tests] 	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
[18:45:35][com.project:tests] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[18:45:35][com.project:tests] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[18:45:35][com.project:tests] 	at java.lang.Thread.run(Thread.java:745)
[18:45:35][com.project:tests] Results :
[18:45:35][com.project:tests] 
[18:45:35][com.project:tests] Failed tests: 
[18:45:35][com.project:tests]   UserPageTests>TestCase.beforeMethod:46 ? WebDriver chrome not reachable
[18:45:35][com.project:tests]   (Dri...
[18:45:35][com.project:tests]   UserPageTests>TestCase.beforeMethod:46 ? WebDriver chrome not reachable
[18:45:35][com.project:tests]   (Dri...
[18:45:35][com.project:tests] 
[18:45:35][com.project:tests] Tests run: 246, Failures: 2, Errors: 0, Skipped: 243
[18:45:35][com.project:tests] 
[18:45:35]
[com.project:tests] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project tests: There are test failures.

Please refer to /root/agent/work/3d76af50ed39a1c0/target/surefire-reports for the individual test results.

Часть 2. Firefox

[18:18:30][com.project:tests] java.net.MalformedURLException: no protocol:
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - Running @Test checkLoadTime
[18:18:30][com.project:tests] 	at java.net.URL.<init>(URL.java:585)
[18:18:30][com.project:tests] 	at java.net.URL.<init>(URL.java:482)
[18:18:30][com.project:tests] 	at java.net.URL.<init>(URL.java:431)
[18:18:30][com.project:tests] 	at com.project.framework.tools.Downloader.getRaw(Downloader.java:16)
[18:18:30][com.project:tests] 	at com.project.tests.MainPageTests.checkLoadTime(MainPageTests.java:66)
[18:18:30][com.project:tests] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[18:18:30][com.project:tests] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - Running @AfterMethod
[18:18:30][com.project:tests] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - Running @BeforeMethod
[18:18:30][com.project:tests] 	at java.lang.reflect.Method.invoke(Method.java:606)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - No annotation @NoBrowser, so trying to run browser
[18:18:30][com.project:tests] 	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - Creating browser
[18:18:30][com.project:tests] 	at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - Untrusted ssl set to:true
[18:18:30][com.project:tests] 	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - Using system driver org.openqa.selenium.firefox.FirefoxDriver
[18:18:30][com.project:tests] 	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - Creating driver org.openqa.selenium.firefox.FirefoxDriver
[18:18:30][com.project:tests] 	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - Trying run driver with firefox profile
[18:18:30][com.project:tests] 	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
[18:18:30][com.project:tests] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - setAcceptUntrustedCertificates: to true
[18:18:30][com.project:tests] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[18:18:30][com.project:tests] 2014-10-29 14:18:30 INFO  [pool-2-thread-1] Logger - setAssumeUntrustedCertificateIssuer: to false
[18:18:30][com.project:tests] 	at java.lang.Thread.run(Thread.java:745)
...
[18:20:37][com.project:tests] Warning: validation was turned on but an org.xml.sax.ErrorHandler was not
[18:20:37][com.project:tests] set, which is probably not what is desired.  Parser will use a default
[18:20:37][com.project:tests] ErrorHandler to print the first 10 errors.  Please call
[18:20:37][com.project:tests] the 'setErrorHandler' method to fix this.
[18:20:37][com.project:tests] Error: URI=null Line=1: Document root element "urlset", must match DOCTYPE root "null".
[18:20:37][com.project:tests] Error: URI=null Line=1: Document is invalid: no grammar found.
[18:20:37][com.project:tests] org.xml.sax.SAXParseException; cvc-elt.1.a: Cannot find the declaration of element 'urlset'.
[18:20:37][com.project:tests] 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)
[18:20:37][com.project:tests] 	at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - Running @AfterMethod
[18:20:37][com.project:tests] 	at javax.xml.validation.Validator.validate(Validator.java:124)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - Running @BeforeMethod
[18:20:37][com.project:tests] 	at com.project.framework.tools.XMLValidator.validate(XMLValidator.java:31)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - No annotation @NoBrowser, so trying to run browser
[18:20:37][com.project:tests] 	at com.project.tests.MainPageTests.checkSitemap(MainPageTests.java:96)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - Creating browser
[18:20:37][com.project:tests] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - Untrusted ssl set to:true
[18:20:37][com.project:tests] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - Using system driver org.openqa.selenium.firefox.FirefoxDriver
[18:20:37][com.project:tests] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - Creating driver org.openqa.selenium.firefox.FirefoxDriver
[18:20:37][com.project:tests] 	at java.lang.reflect.Method.invoke(Method.java:606)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - Trying run driver with firefox profile
[18:20:37][com.project:tests] 	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - setAcceptUntrustedCertificates: to true
[18:20:37][com.project:tests] 	at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
[18:20:37][com.project:tests] 2014-10-29 14:20:37 INFO  [pool-2-thread-1] Logger - setAssumeUntrustedCertificateIssuer: to false
[18:20:37][com.project:tests] 	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
[18:20:37][com.project:tests] 	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
[18:20:37][com.project:tests] 	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
[18:20:37][com.project:tests] 	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
[18:20:37][com.project:tests] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[18:20:37][com.project:tests] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[18:20:37][com.project:tests] 	at java.lang.Thread.run(Thread.java:745)
...
[18:28:05][com.project:tests] Tests run: 47, Failures: 35, Errors: 0, Skipped: 4, Time elapsed: 2,261.79 sec <<< FAILURE! - in TestSuite
[18:28:05][com.project:tests] checkMetricCounter(com.project.tests.UserPageTests)  Time elapsed: 60.124 sec  <<< FAILURE!
[18:28:05][com.project:tests] org.openqa.selenium.TimeoutException: Timed out waiting for page load.
[18:28:05][com.project:tests] Command duration or timeout: 60.10 seconds
[18:28:05][com.project:tests] Build info: version: '2.43.1', revision: '5163bceef1bc36d43f3dc0b83c88998168a363a0', time: '2014-09-10 09:43:55'
[18:28:05][com.project:tests] System info: host: 'host', ip: '10.10.10.100', os.name: 'Linux', os.arch: 'i386', os.version: '2.6.32-22-pve', java.version: '1.7.0_67'
[18:28:05][com.project:tests] Session ID: cde30b07-fa0a-4493-b63f-a59d621d4da9
[18:28:05][com.project:tests] Driver info: org.openqa.selenium.firefox.FirefoxDriver
[18:28:05][com.project:tests] Capabilities [{platform=LINUX, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, webStorageEnabled=true, nativeEvents=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=33.0}]
[18:28:05][com.project:tests] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[18:28:05][com.project:tests] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[18:28:05][com.project:tests] 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[18:28:05][com.project:tests] 	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
[18:28:05][com.project:tests] 	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
[18:28:05][com.project:tests] 	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
[18:28:05][com.project:tests] 	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
[18:28:05][com.project:tests] 	at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:304)
[18:28:05][com.project:tests] 	at com.project.framework.browser.Browser.get(Browser.java:104)
[18:28:05][com.project:tests] 	at com.project.framework.pages.impl.UserPage.load(UserPage.java:31)
[18:28:05][com.project:tests] 	at org.openqa.selenium.support.ui.LoadableComponent.get(LoadableComponent.java:48)
[18:28:05][com.project:tests] 	at com.project.tests.UserPageTests$3.<init>(UserPageTests.java:65)
[18:28:05][com.project:tests] 	at com.project.tests.UserPageTests.checkMetricCounter(UserPageTests.java:63)
[18:28:05][com.project:tests] Caused by: org.openqa.selenium.TimeoutException: Timed out waiting for page load.
[18:28:05][com.project:tests] Build info: version: '2.43.1', revision: '5163bceef1bc36d43f3dc0b83c88998168a363a0', time: '2014-09-10 09:43:55'
[18:28:05][com.project:tests] System info: host: 'host', ip: '10.10.10.100', os.name: 'Linux', os.arch: 'i386', os.version: '2.6.32-22-pve', java.version: '1.7.0_67'
[18:28:05][com.project:tests] Driver info: driver.version: unknown
[18:28:05][com.project:tests] 	at <anonymous class>.Utils.initWebLoadingListener/<(file:///tmp/anonymous2053335594943508161webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:7974:56)
[18:28:05][com.project:tests] 	at <anonymous class>.WebLoadingListener/e(file:///tmp/anonymous2053335594943508161webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:4120:7)
[18:28:05][com.project:tests] 	at <anonymous class>.WebLoadingListener/<(file:///tmp/anonymous2053335594943508161webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:4128:7)
[18:28:05][com.project:tests] 	at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///tmp/anonymous2053335594943508161webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:548:5)

Содержание pom-файла: 

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>

    <groupId>com.project</groupId>
    <artifactId>tests</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.5</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.43.1</version>
        </dependency>
        <dependency>
            <groupId>org.uncommons</groupId>
            <artifactId>reportng</artifactId>
            <version>1.1.4</version>
            <exclusions>
                <exclusion>
                    <groupId>org.testng</groupId>
                    <artifactId>testng</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.7</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>${basedir}/src/test/resources/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <systemPropertyVariables>
                        <com.project.tests.untrusted.ssl>true</com.project.tests.untrusted.ssl>
                        <com.project.tests.expected.loadtime>3000</com.project.tests.expected.loadtime>
                        <com.project.tests.check.gmail>false</com.project.tests.check.gmail>
                        <com.project.tests.gmail.timeout>15</com.project.tests.gmail.timeout>
                        <com.project.tests.gmail.user>user</com.project.tests.gmail.user>
                        <com.project.tests.gmail.pass>pass</com.project.tests.gmail.pass>
                        <com.project.tests.gmail.imap.host>imap.gmail.com</com.project.tests.gmail.imap.host>
                        <com.project.tests.gmail.smtp.host>smtp.gmail.com</com.project.tests.gmail.smtp.host>
                        <com.project.tests.webdriver>org.openqa.selenium.chrome.ChromeDriver</com.project.tests.webdriver>
                        <!-- <com.project.tests.webdriver>org.openqa.selenium.firefox.FirefoxDriver</com.project.tests.webdriver> -->
                        <org.uncommons.reportng.escape-output>false</org.uncommons.reportng.escape-output>
                        <com.project.tests.sitemap.xsd>${basedir}/src/test/resources/sitemap.xsd</com.project.tests.sitemap.xsd>
                        <webdriver.chrome.driver>${basedir}/src/test/resources/chromedriver</webdriver.chrome.driver>
                        <com.project.tests.url>https://project.ru</com.project.tests.url>
                        <com.project.tests.disable.pageload>false</com.project.tests.disable.pageload>
                        <com.project.tests.timeout.pageload>60</com.project.tests.timeout.pageload>
                        <com.project.tests.timeout.script>5</com.project.tests.timeout.script>
                        <com.project.tests.timeout.wait>7</com.project.tests.timeout.wait>
                    </systemPropertyVariables>
                    <properties>
                        <property>
                            <name>usedefaultlisteners</name>
                            <value>false</value>
                        </property>
                        <property>
                            <name>listener</name>
                            <value>org.uncommons.reportng.HTMLReporter</value>
                        </property>
                    </properties>
                    <workingDirectory>target/</workingDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Класс браузера: 

package com.project.framework.browser;

import com.google.common.base.Predicate;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.File;
import java.io.IOException;

import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public class Browser implements WebDriver {
	private WebDriver driver;

	public class BrowserProperty {
		public static final String SYSTEM_WEB_DRIVER_PROPERTY = "com.project.tests.webdriver";
		public static final String TEST_BASE_URL_PROPERTY = "com.project.tests.url";
		public static final String DISABLE_PAGE_LOAD_TIMEOUT = "com.project.tests.disable.pageload";
		public static final String UNTRUSTED_SSL="com.project.tests.untrusted.ssl";
	}

	public static String TEST_BASE_URL = System.getProperty(BrowserProperty.TEST_BASE_URL_PROPERTY);

	public Browser() {
		log("Creating browser");
		try {
			driver = getSystemDriver();
			setDefaultTimeouts();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		}
	}

	public Browser(WebDriver driver, boolean setDefaultTimeouts) {
		log("Creating browser");
		log("Using driver: "+driver);
		this.driver = driver;
		if (setDefaultTimeouts) {
			setDefaultTimeouts();
		}
	}

	private WebDriver getSystemDriver() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String driverName = System.getProperty(BrowserProperty.SYSTEM_WEB_DRIVER_PROPERTY);
		boolean untrustedSSL = Boolean.parseBoolean(System.getProperty(BrowserProperty.UNTRUSTED_SSL));
		log("Untrusted ssl set to:"+untrustedSSL);
		log("Using system driver "+driverName);
		if (driverName == null) {
			log("System driver null, creating FirefoxDriver");
			return new FirefoxDriver();
		} else {
			log("Creating driver "+driverName);
			if(driverName.contains("ChromeDriver") && untrustedSSL ){
				return chromeSSL();
			}
			if(driverName.contains("FirefoxDriver") && untrustedSSL ){
				return firefoxSSL();
			}
			return (WebDriver) Class.forName(driverName).newInstance();
		}
	}

	private WebDriver chromeSSL(){
		log("Trying run driver with ignoring untrusted ssl certs");
		List<String> switches= Arrays.asList("--ignore-certificate-errors","--no-sandbox");
		log("Set capability"+switches);
		DesiredCapabilities capabilities = DesiredCapabilities.chrome();
		capabilities.setCapability("chrome.switches", switches);
		return new ChromeDriver(capabilities);
	}

	private WebDriver firefoxSSL(){
		log("Trying run driver with firefox profile");
		FirefoxProfile profile= new FirefoxProfile();
		log("setAcceptUntrustedCertificates: to true");
		profile.setAcceptUntrustedCertificates(true);
		log("setAssumeUntrustedCertificateIssuer: to false");
		profile.setAssumeUntrustedCertificateIssuer(false);
		return new FirefoxDriver(profile);
	}

	public void get(String url) {
		log("Get url "+url);
		driver.get(url);
	}

	public String getCurrentUrl() {
		log("Return current page url");
		return driver.getCurrentUrl();
	}

	public String getTitle() {
		log("Return title");
		return driver.getTitle();
	}

	public List<WebElement> findElements(By by) {
		log("Trying to find all elements "+by);
		return driver.findElements(by);
	}

	public WebElement findElement(By by) {
		log("Trying to find element "+by);
		return driver.findElement(by);
	}

	public String getPageSource() {
		log("Return current page source");
		return driver.getPageSource();
	}

	public void close() {
		log("Close current window");
		driver.close();
	}

	public void quit() {
		log("Quit from browser");
		driver.quit();
	}

	public Set<String> getWindowHandles() {
		return driver.getWindowHandles();
	}

	public String getWindowHandle() {
		return driver.getWindowHandle();
	}

	public TargetLocator switchTo() {
		return driver.switchTo();
	}

	public Navigation navigate() {
		return driver.navigate();
	}

	public Options manage() {
		return driver.manage();
	}

	public Object executeScript(String script, Object... args) {
		log("Execute script "+script);
		return ((JavascriptExecutor) driver).executeScript(script, args);
	}

	public String takeScreenshotAsFile(String outputDirectory) {
		log("Trying to get screenshot as file");
		try {
			File source = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
			outputDirectory += "/" + source.getName();
			File destination = new File(outputDirectory);
			FileUtils.copyFile(source, destination);
			outputDirectory = destination.getAbsolutePath();
		} catch (IOException e) {
			outputDirectory = "Failed to capture screenshot: " + e.getMessage();
		}
		return outputDirectory;
	}

	public String takeScreenshotAsBase64(){
		log("Trying to get screenshot as base64 string");
		return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64);
	}

	public void sleep(long timeout) {
		try {
			hold(timeout).until(new Predicate<WebDriver>() {
				public boolean apply(WebDriver arg0) {
					return false;
				}
			});
		} catch (Exception e) {
		}
	}

	class DefaultTimeouts {
		public static final long PAGE_LOAD = 60;
		public static final long IMPLICIT_WAIT = 5;
		public static final long EXECUTE_SCRIPT = 5;
	}

	private void setDefaultTimeouts() {
		log("Setting default timeouts:");
		log("Set implicit wait:"+DefaultTimeouts.IMPLICIT_WAIT+" seconds");
		driver.manage().timeouts().implicitlyWait(DefaultTimeouts.IMPLICIT_WAIT, TimeUnit.SECONDS);
		log("Set execute script:"+DefaultTimeouts.EXECUTE_SCRIPT+" seconds");
		driver.manage().timeouts().setScriptTimeout(DefaultTimeouts.EXECUTE_SCRIPT, TimeUnit.SECONDS);
		if (System.getProperty(BrowserProperty.DISABLE_PAGE_LOAD_TIMEOUT).equals("false")) {
			log("Set page load:"+DefaultTimeouts.PAGE_LOAD+" seconds");
			driver.manage().timeouts().pageLoadTimeout(DefaultTimeouts.PAGE_LOAD, TimeUnit.SECONDS);
		}else{
			log("Found property "+BrowserProperty.DISABLE_PAGE_LOAD_TIMEOUT+". Page load will not be set!");
		}
	}

	public WebDriverWait hold(long time){
		log("Return new waiter object with timeout "+time);
		return new WebDriverWait(this,time);
	}


	public WebDriver getDriver(){
		log("Returning driver to test");
		return this.driver;
	}
}

Прошу совета. 


  • 0

#2 barancev

barancev

    Администратор

  • Admin
  • PipPipPipPipPipPip
  • 6 815 сообщений
  • ФИО:Алексей Баранцев
  • Город:Россия, Москва


Отправлено 31 Октябрь 2014 - 15:49

1. Про Chrome не могу сказать, может быть баг, а может быть случайный сбой. Не прошло 2 теста из 246 -- если и баг, то трудноуловимый.

 

2. Про Firefox.

 

Первый приведённый сбой содержит вполне нормальное сообщение и указывает на причину сбоя:

java.net.MalformedURLException: no protocol

Смотрите, что там такое без указания протокола Вы пытаетесь открывать в MainPageTests.java:66

 

Второй приведённый сбой ничуть не хуже описывает причину сбоя:

org.openqa.selenium.TimeoutException: Timed out waiting for page load

Страница не успела загрузиться. Почему -- откуда же мы угадаем, не видя страницу и не зная, что там происходит.


  • 0

Алексей Баранцев
Тренинги для тестировщиков (тестирование производительности, защищенности, тест-дизайн, автоматизация):
Линейка тренингов по Selenium



Selenium 2.0: стартовый уровень
онлайн, начало 9 ноября
Программирование на Java для тестировщиков
онлайн, начало 16 ноября
Автоматизация функционального тестирования
онлайн, начало 9 ноября
Selenium WebDriver: полное руководство
онлайн, начало 19 октября




Темы с аналогичным тегами Teamcity, Maven, WebDriver, ChromeDriver, FirefoxDriver, Java, тесты, PHP, Git, Ubuntu

Количество пользователей, читающих эту тему: 0

0 пользователей, 0 гостей, 0 анонимных

Яндекс.Метрика
Реклама на портале