os.env('MONGO_IP_PROD')
System.getenv("MONGO_IP_PROD");
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.ddl-auto=create
create-drop
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.ddl-auto=create
create-drop
package example;
/**
* Copyright 2021 Serguei Kouzmine
*/
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.IOException;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
// TODO: get rid of
import com.neovisionaries.ws.client.WebSocketException;
import example.messaging.MessageBuilder;
public class UserAgentOverrideTest extends BaseTest {
private static final By locator = By.xpath(
"//*[@id=\"content-base\"]//table//th[contains(text(),\"USER-AGENT\")]/../td");
private static String baseURL = "https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending";
private static WebElement element = null;
@Ignore
@Test
public void setUserAgentOverrideTest() {
// Arrange
driver.get(baseURL);
element = driver.findElement(locator);
// TODO:
// utils.highlight(element);
utils.sleep(100);
assertThat(element.getAttribute("innerText"), containsString("Mozilla"));
// Act
try {
CDPClient.sendMessage(MessageBuilder
.buildSetUserAgentOverrideMessage("my agent", "windows"));
} catch (IOException | WebSocketException e) {
// ignore
System.err.println("Exception (ignored): " + e.toString());
}
driver.navigate().refresh();
utils.sleep(1);
element = driver.findElement(locator);
assertThat(element.isDisplayed(), is(true));
assertThat(element.getAttribute("innerText"), is("my agent"));
}
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# based on: https://stackoverflow.com/questions/74793705/how-to-load-chrome-options-using-undetected-chrome
# uses CDP to override the user agent header
# origin: https://habr.com/ru/post/459112/
# see also:
import time,os,sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import json, base64
def send_command_return_result(driver, cmd, params = {}, resultkey = 'windowId'):
post_url = driver.command_executor._url + '/session/{0:s}/chromium/send_command_and_get_result'.format( driver.session_id)
response = driver.command_executor._request('POST', post_url, json.dumps({'cmd': cmd, 'params': params}))
print('response: {}'.format(response))
if ('status' in response ) and response['status']:
raise Exception(response.get('value'))
return response.get('value').get(resultkey)
def send_command(driver, cmd, params = {}):
post_url = driver.command_executor._url + '/session/{0:s}/chromium/send_command_and_get_result'.format( driver.session_id)
response = driver.command_executor._request('POST', post_url, json.dumps({'cmd': cmd, 'params': params}))
if ('status' in response ) and response['status']:
raise Exception(response.get('value'))
global debug
debug = False
if __name__ == '__main__':
webdriver_options = Options()
# to see the page
# webdriver_options.add_argument('--headless')
webdriver_options.add_argument('--disable-gpu')
if os.getenv('OS') != None :
homedir = os.getenv('USERPROFILE').replace('\\', '/')
is_windows = True
else:
homedir = os.getenv('HOME')
is_windows = False
chromedriver_path = homedir + os.sep + 'Downloads' + os.sep + ('chromedriver.exe' if is_windows else 'chromedriver')
driver = webdriver.Chrome(chromedriver_path, options = webdriver_options)
# https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setUserAgentOverride
send_command(driver,
'Network.setUserAgentOverride', {
'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0',
}
)
url = 'https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending'
driver.get(url)
time.sleep(10)
driver.quit()
# PATH=%PATH%;c:\Python381;%USERPROFILE%\Downloads
options.add_argument('--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0"')
NAME1=xxx1
IMAGE1=yyy1
docker build -t $IMAGE1 -f Dockerfile1 .
docker run -d --name $NAME1 $IMAGE1
NAME2=xxx2
IMAGE2=yyy2
docker build -t $IMAGE2 -f Dockerfile2 .
docker run -it --name $NAME2 --link $NAME1 $IMAGE2 sh
когда ого нормально написаное то понимает в рантайме с полуслова