LINUX.ORG.RU

Правильные setCapability для запуска chrome в android

 


0

1

Тестирую этот проект https://github.com/aerokube/demo-tests

Запущенные контейнеры

 docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                    NAMES
ffd64121947a        aerokube/selenoid:latest      "/usr/bin/selenoid -…"   3 days ago          Up 3 days           0.0.0.0:4444->4444/tcp   selenoid
c7c74a3b6589        aerokube/selenoid-ui:latest   "/selenoid-ui --sele…"   3 days ago          Up 3 days           0.0.0.0:8080->8080/tcp   selenoid-ui

Логи ffd64121947a

docker logs ffd64121947a
2019/12/02 12:16:03 [3258] [LOCATING_SERVICE] [chrome] [6.0]
2019/12/02 12:16:03 [3258] [ENVIRONMENT_NOT_AVAILABLE] [chrome] [6.0]

browsers.json:

{
    "android": {
        "default": "6.0",
        "versions": {
            "6.0": {
                "image": "nexus/selenoid/android:6.0",
                "port": "4444",
                "path": "/wd/hub"
            }
        }
    },
    "chrome": {
        "default": "78.0",
        "versions": {
            "78.0": {
                "image": "nexus/selenoid/chrome:78.0",
                "port": "4444",
                "path": "/"
            }
        }
    }
}

Прокси поправил

package com.aerokube.selenoid;

import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.io.File;
import java.net.URL;

import static com.aerokube.selenoid.Screenshot.takeScreenshot;

public class DemoTest {

    private RemoteWebDriver driver;

    @Before
    public void openDriver() throws Exception {
        Proxy proxy = new Proxy();
        proxy.setSslProxy("http://proxy:3128");
        final DesiredCapabilities browser = DesiredCapabilities.chrome();
        browser.setCapability("deviceName", "android");
        browser.setCapability("version", "6.0");
        browser.setCapability("appPackage", "com.android.chrome");
        browser.setCapability("appActivity", "com.google.android.apps.chrome.Main");
        browser.setCapability("proxy", proxy);
        browser.setCapability("enableVideo", true);
        browser.setCapability("enableLog", true);
        browser.setCapability("enableVNC", true);
        driver = new RemoteWebDriver(new URL(
                "http://localhost:4444/wd/hub" //Replace with correct host and port
        ), browser);
    }

    @Test
    public void browserTest() throws Exception {
        try {
            driver.get("https://duckduckgo.com/");
            WebElement input = driver.findElement(By.cssSelector("input#search_form_input_homepage"));
            input.sendKeys(Keys.chord("selenium", Keys.ENTER));
        } finally {
            takeScreenshot(driver);
        }

    }

    @After
    public void closeDriver(){
        if (driver != null){
            driver.quit();
            driver = null;
        }
    }
}


Пишет:

Tests in error: 
  browserTest(com.aerokube.selenoid.DemoTest): Requested environment is not available (WARNING: The server did not provide any stacktrace information)

Как исправить ошибку?

Ответ на: комментарий от TheKnight

Судя по этой странице https://aerokube.com/selenoid/latest/ версия Appium 1.13

Здесь пусто ~/.aerokube/selenoid/logs

Это образы android с Appium от команды aerokube. Спрошу у них

chemtech ()
Последнее исправление: chemtech (всего исправлений: 1)
Ответ на: комментарий от TheKnight

Вот так начало запускаться

https://github.com/aerokube/selenoid/issues/843

Но сейчас ошибка:

Tests in error: 
  browserTest(com.aerokube.selenoid.DemoTest): Unable to parse remote response: The URL '/session' did not map to a valid resource

и в логах docker selenoid

2019/12/02 14:00:56 [202] [SERVICE_STARTED] [nexus:10443/selenoid/chrome-mobile:75.0] [a17e5ae79cea946206420bb4e169772709c75bca60133721215b6d11cf5b1a69] [17.52s]
2019/12/02 14:00:56 [202] [PROXY_TO] [a17e5ae79cea946206420bb4e169772709c75bca60133721215b6d11cf5b1a69] [http://172.17.0.4:4444/]
2019/12/02 14:00:56 [202] [SESSION_ATTEMPTED] [http://172.17.0.4:4444/] [1]
2019/12/02 14:00:56 [202] [SESSION_FAILED] [http://172.17.0.4:4444/] [404 Not Found]
2019/12/02 14:00:56 [202] [STOPPING_VIDEO_CONTAINER] [f45051633d03afee462747bb4030ec348fdac39bd1fa178a42b7e5921a8f6aca]
2019/12/02 14:00:56 [202] [REMOVING_CONTAINER] [f45051633d03afee462747bb4030ec348fdac39bd1fa178a42b7e5921a8f6aca]
2019/12/02 14:00:56 [202] [FAILED_TO_REMOVE_CONTAINER] [f45051633d03afee462747bb4030ec348fdac39bd1fa178a42b7e5921a8f6aca] [Error response from daemon: removal of container f45051633d03afee462747bb4030ec348fdac39bd1fa178a42b7e5921a8f6aca is already in progress]
2019/12/02 14:00:56 [202] [REMOVING_CONTAINER] [a17e5ae79cea946206420bb4e169772709c75bca60133721215b6d11cf5b1a69]
2019/12/02 14:00:58 [202] [CONTAINER_REMOVED] [a17e5ae79cea946206420bb4e169772709c75bca60133721215b6d11cf5b1a69]
chemtech ()
Последнее исправление: chemtech (всего исправлений: 1)