#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from os import getenv
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoAlertPresentException
from selenium.common.exceptions import TimeoutException
if __name__ == '__main__':
driver = webdriver.Firefox()
driver.maximize_window()
if getenv('OS') != None :
homedir = getenv('HOMEDIR').replace('\\', '/')
else:
homedir = getenv('HOME')
location = 'file:///{0}/{1}'.format('{0}/Downloads'.format(homedir),'localized_text.html')
driver.get(location)
xpath = '//div[@id="up_file_name"]/label'
expected_text = u'Ошибка: неверный формат файла'
try:
WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH, xpath)))
element = driver.find_element_by_xpath(xpath )
assert element.text.encode('utf8','ignore').decode('utf8') == expected_text
print('Verified Text of Element: "{0}"'.format(element.text.encode('utf8','ignore')) )
except ( TimeoutException) as e:
print('Element is not located: '.format(e))
print (e.args)
finally:
driver.quit()
<html>
<body>
<h1>Localized Page Demo</h1>
<div id="up_file_name" class="form-group has-error">
<label class="control-label">Ошибка: неверный формат файла</label>
<input class="file" type="hidden" name="uploaded-file" value="0" data-point="10" data-texterrortobigfile="Вы хотите загрузить слишком большой файл: пожалуйста внимательно прочитайте требования по размеру загружаемого файла." data-texterroruploadfail="Не загружено резюме">
</div>
</body>
</html>
sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName
...
ARG params
ENV params_env=$params
ENTRYPOINT ["java", "-Dparams=${params_env}", "-jar", "app.jar" ]
docker build -f Dockerfile -t basic-args-example --build-arg "params=eyJpZCI6MH0K".
ARG
а из него в ENV
и уж из него в ENTRYOINT
{"id":0}
class element_to_be_clickable(object):
""" An Expectation for checking an element is visible and enabled such that
you can click it."""
def __init__(self, locator):
self.locator = locator
def __call__(self, driver):
element = visibility_of_element_located(self.locator)(driver)
if element and element.is_enabled():
return element
else:
return False
class visibility_of_element_located(object):
""" An expectation for checking that an element is present on the DOM of a
page and visible. Visibility means that the element is not only displayed
but also has a height and width that is greater than 0.
locator - used to find the element
returns the WebElement once it is located and visible
"""
def __init__(self, locator):
self.locator = locator
def __call__(self, driver):
try:
return _element_if_visible(_find_element(driver, self.locator))
except StaleElementReferenceException:
return False
# based on examples from https://docs.microsoft.com/en-us/dotnet/api/system.consolekey?view=netframework-4.5
function WriteAt {
param(
[string] $s,
[int] $x,
[int] $y
)
[System.Console]::SetCursorPosition($origCol + $x, $origRow + $y )
[System.Console]::Write($s)
}
[System.Console]::Clear( )
$origRow = [System.Console]::CursorTop;
$origCol = [System.Console]::CursorLeft;
# Draw the left side of a 5x5 rectangle, from top to bottom.
WriteAt '+' 0 0
WriteAt '|' 0 1
WriteAt '|' 0 2
WriteAt '|' 0 3
WriteAt '+' 0 4
# Draw the bottom side, from left to right.
WriteAt '---' 1 4
# Draw the right side, from bottom to top.
WriteAt '|' 4 3
WriteAt '|' 4 2
WriteAt '|' 4 1
WriteAt '+' 4 0
# Draw the top side, from right to left.
WriteAt '---', 1 0
WriteAt 'Press Enter to quit!' 0 6
[System.Console]::WriteLine( )
while ([System.Console]::ReadKey().Key -ne [System.ConsoleKey]::Enter) {
sleep 1;
}
Application.java
@Value("${appname}")
private String appname;
@GetMapping
public String Hello() {
return "This is " + appname;
Dockerfile
ENTRYPOINT ["java", "-Dappname=my docker appication", "-jar", "app.jar" ]
mvn -Dmaven.test.skip=true clean package
docker build -f Dockerfile -t basic-args-example .
docker run -p 8080:8080 basic-args-example
curl http://localhost:8080/basic
This is my docker application
SHELL ENTRYPOINT
- сам пока осваиваю