import os.path
>>> print os.path.isfile("/etc/password.txt")
True
>>> print os.path.isfile("/etc")
False
>>> print os.path.exists("/etc/password.txt")
True
>>> print os.path.exists("/etc")
True
class LoginView:
def __init__(self):
self.viewname='ABC'
def enter(self):
tf.executeApiCall()
def wait_for_view(self):
tf.wait_for_view(self.viewname)
def press_cancel_button(self):
tf.press_widget('xyz.ABC')
def enter_username(self, u):
tf.enter_string('xyz.ABC.inputfield', u)
def check_error_popup_visible(self,expect):
if expect==True:
tf.wait_for_view(view='xyz.ABC.LoginErrorPopup')
else:
tf.wait_for_view(notinview='xyz.ABC.LoginErrorPopup')
def press_login_button(self):
tf.press_widget('xyz.ABC.Login')
username='Kolya'
main_view = MainView()
login_view = LoginView()
login_view.enter()
login_view.wait_for_view()
login_view.enter_username(u=username)
login_view.press_login_button()
login_view.check_error_popup_visible(expect=True)
login_view.confirm_error_popup()
login_view.check_error_popup_visible(expect=False)
login_view.check_inputfield_text_equals(expect=username)
login_view.leave()
main_view.wait_for_view()
a = [12,35,49]
bracket = 3;
result = []
for x in a:
for i in range(-bracket,bracket+1):
result.append(x+i);
print result
items = [12,35,49]
bracket = 3
result = sum(list(map(lambda x: range(x-bracket,x+bracket+1), items)),[])
print result
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
import os
binary = FirefoxBinary(r'C:\PortableApps.com\PortableApps\FirefoxPortable\App\Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)
driver.get("https://perevod.mtbank.by/")
elem = driver.find_element_by_name("from0")
elem.clear()
elem.send_keys("1234234563456456723")
elem1 = driver.find_element_by_name("to0")
elem1.send_keys("1234234563456456723")
driver.close()
from bottle import route, run, template, response
import random
@route('/reg/<name>/<pw>')
def index(name, pw):
cookie_hash = random.randrange(10000000000)
response.set_header('Set-Cookie', 'cookie_hash=%s' % (cookie_hash))
return template('<b>Hello {{name}}, {{hash}}, {{pw}} </b>!', name=name, hash=cookie_hash, pw=pw)
run(host='localhost', port=8080)