Всем привет
Подскажите, пожалуйста)
Проблема заключается в том, что не удается получить запросы при помощи selenide proxy. Har файл пустой по окончанию прогона
Делал по Как получить сетевые запросы с помощью прокси
Код
public class DriverFactory implements WebDriverProvider {
private WebDriver driver;
@Nonnull
@Override
public WebDriver createDriver(@Nonnull Capabilities capabilities) {
if (driver == null) {
ChromeOptions options = configureChromeOptions(capabilities);
driver = new ChromeDriver(options);
driver = addJSDrawer(driver);
}
return driver;
}
private ChromeOptions configureChromeOptions(Capabilities capabilities) {
LoggingPreferences logs = new LoggingPreferences();
ChromeOptions options = new ChromeOptions();
logs.enable(LogType.BROWSER, Level.ALL);
logs.enable(LogType.CLIENT, Level.SEVERE);
logs.enable(LogType.DRIVER, Level.WARNING);
logs.enable(LogType.PERFORMANCE, Level.INFO);
logs.enable(LogType.SERVER, Level.ALL);
HashMap<String, Object> chromePreferences = new HashMap<>();
chromePreferences.put("profile.password_manager_enabled", "false");
options.addArguments("--no-default-browser-check");
options.addArguments("--disable-extensions");
options.addArguments("--disable-web-security");
options.addArguments("--use-fake-device-for-media-stream");
options.addArguments("--use-fake-ui-for-media-stream");
options.addArguments("--test-type");
options.addArguments("--no-sandbox");
options.addArguments("--enable-strict-powerful-feature-restrictions");
options.addArguments("browser.download.folderList=2");
options.addArguments("profile.default_content_settings.popups=0");
options.addArguments("download.prompt_for_download=false");
options.addArguments("download.default_directory=" + Env.DOWNLOAD_DIR);
options.addArguments("browser.download.useDownloadDir=true");
options.addArguments("browser.helperApps.neverAsk.saveToDisk=application/pdf");
options.addArguments("pdfjs.disabled=true");
options.addArguments("--start-maximized");
options.addArguments("--disable-features=VizDisplayCompositor");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--disable-3d-apis");
options.setCapability(ACCEPT_INSECURE_CERTS, true);
options.setCapability("browserName", "chrome");
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
options.setCapability("goog:loggingPrefs", logs);
options.setExperimentalOption("prefs", chromePreferences);
options.merge(capabilities);
return options;
}
public static void configureSelenide() {
Configuration.browser = DriverFactory.class.getName();
Configuration.timeout = Env.WAIT_SELENIDE;
Configuration.reportsFolder = "target/screenshots";
Configuration.savePageSource = false;
Configuration.screenshots = false;
Configuration.proxyEnabled = true;
//Configuration.proxyHost = new org.openqa.selenium.net.NetworkUtils().getNonLoopbackAddressOfThisMachine();
Configuration.proxyPort = 4445;
Configuration.pageLoadTimeout = Env.WAIT_ELEMENT * 24000L;
if (remote) {
Configuration.proxyHost = new org.openqa.selenium.net.NetworkUtils().getNonLoopbackAddressOfThisMachine();
Configuration.remote = SELENIDE_URL;
Configuration.headless = true;
}
}
public abstract class BaseSettings {
@BeforeMethod(alwaysRun = true)
public void setForUi(ITestContext ctx) {
try {
DriverFactory.configureSelenide();
open(url);
HarReader.getHar(WebDriverRunner.getSelenideProxy().getProxy()); }
public static void getHar(BrowserUpProxy proxy) {
proxy.setHarCaptureTypes(CaptureType.getAllContentCaptureTypes());
proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
proxy.newHar("pofig");
}
Во время прогона при вызове WebDriverRunner.getSelenideProxy().getProxy() получаю что har файл создается, но в него ничего не записывается. Что можно сделать?
Хотя прокси задан и вроде как слушает
Dependency следующие
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>7.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.valfirst.browserup-proxy</groupId>
<artifactId>browserup-proxy-core</artifactId>
<version>2.2.16</version>
<scope>compile</scope>
</dependency>
Также проблема номер 2. Не удается запустить тесты удаленно используя селеноид. Падает именно на методе open()
Ошибка
Ошибка: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 400. Message: Requested environment is not available
Host info: host: ‘pc’, ip: ‘192.168.0.195’
Build info: version: ‘4.18.1’, revision: ‘b1d3319b48’
System info: os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘6.5.0-28-generic’, java.version: ‘17.0.9’
selenide.remote: https://selenoid-…stage.felix.online/wd/hub
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, pageLoadStrategy: normal, proxy: Proxy(manual, http=192.168…, unhandledPromptBehavior: accept}]}]
selenide.url: https://felix-169…86-1-j-r-debug-felix.stage.felix.online
Capabilities {acceptInsecureCerts: true, pageLoadStrategy: normal, proxy: Proxy(manual, http=192.168…, unhandledPromptBehavior: accept}
selenide.baseUrl: http://localhost:8080
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:139) | |
---|---|
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:95) | |
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67) | |
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:162) | |
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:519) | |
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:233) | |
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:162) | |
at com.codeborne.selenide.webdriver.RemoteDriverFactory.create(RemoteDriverFactory.java:24) | |
at com.codeborne.selenide.webdriver.WebDriverFactory.createWebDriverInstance(WebDriverFactory.java:114) | |
at com.codeborne.selenide.webdriver.WebDriverFactory.createWebDriver(WebDriverFactory.java:67) | |
at com.codeborne.selenide.drivercommands.CreateDriverCommand.lambda$createDriver$0(CreateDriverCommand.java:72) | |
at com.codeborne.selenide.logevents.SelenideLogger.wrap(SelenideLogger.java:133) | |
at com.codeborne.selenide.logevents.SelenideLogger.get(SelenideLogger.java:113) | |
at com.codeborne.selenide.drivercommands.CreateDriverCommand.createDriver(CreateDriverCommand.java:48) | |
at com.codeborne.selenide.impl.WebDriverThreadLocalContainer.createDriver(WebDriverThreadLocalContainer.java:189) | |
at com.codeborne.selenide.impl.WebDriverThreadLocalContainer.createAndRegisterDriver(WebDriverThreadLocalContainer.java:174) | |
at com.codeborne.selenide.impl.WebDriverThreadLocalContainer.getAndCheckWebDriver(WebDriverThreadLocalContainer.java:136) | |
at com.codeborne.selenide.WebDriverRunner.getAndCheckWebDriver(WebDriverRunner.java:113) | |
at com.codeborne.selenide.impl.StaticDriver.getAndCheckWebDriver(StaticDriver.java:65) | |
at com.codeborne.selenide.SelenideDriver.getAndCheckWebDriver(SelenideDriver.java:211) | |
at com.codeborne.selenide.drivercommands.Navigator.lambda$navigateTo$0(Navigator.java:70) | |
at com.codeborne.selenide.logevents.SelenideLogger.lambda$run$0(SelenideLogger.java:105) | |
at com.codeborne.selenide.logevents.SelenideLogger.wrap(SelenideLogger.java:133) | |
at com.codeborne.selenide.logevents.SelenideLogger.run(SelenideLogger.java:104) | |
at com.codeborne.selenide.drivercommands.Navigator.navigateTo(Navigator.java:68) | |
at com.codeborne.selenide.drivercommands.Navigator.open(Navigator.java:31) | |
at com.codeborne.selenide.SelenideDriver.open(SelenideDriver.java:93) | |
at com.codeborne.selenide.Selenide.open(Selenide.java:53) | |
at raketa.base.TestBaseUi.instantiateUi(TestBaseUi.java:86) | |
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) | |
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.base/java.lang.reflect.Method.invoke(Method.java:568) | |
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139) | |
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:69) | |
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:393) | |
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:326) | |
at org.testng.internal.invokers.TestInvoker.runConfigMethods(TestInvoker.java:810) | |
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:578) | |
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:228) | |
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:63) | |
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:961) | |
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:201) | |
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148) | |
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128) | |
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) | |
at org.testng.TestRunner.privateRun(TestRunner.java:819) | |
at org.testng.TestRunner.run(TestRunner.java:619) | |
at org.testng.SuiteRunner.runTest(SuiteRunner.java:443) | |
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:437) | |
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:397) | |
at org.testng.SuiteRunner.run(SuiteRunner.java:336) | |
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) | |
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95) | |
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301) | |
at org.testng.TestNG.runSuitesLocally(TestNG.java:1228) | |
at org.testng.TestNG.runSuites(TestNG.java:1134) | |
at org.testng.TestNG.run(TestNG.java:1101) | |
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:65) | |
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105) |