本文整理汇总了Python中selenium.webdriver.Remote.maximize_window方法的典型用法代码示例。如果您正苦于以下问题:Python Remote.maximize_window方法的具体用法?Python Remote.maximize_window怎么用?Python Remote.maximize_window使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.Remote
的用法示例。
在下文中一共展示了Remote.maximize_window方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_open_driver
# 需要导入模块: from selenium.webdriver import Remote [as 别名]
# 或者: from selenium.webdriver.Remote import maximize_window [as 别名]
def test_open_driver(self,host,brower):
driver = Remote(command_executor=host,
desired_capabilities=brower
)
# fileList = fileRead().get_ip_address()
# ipAdd = fileList[0].strip('\n')
driver.maximize_window()
driver.get("https://" + ipAdd + "/fort")
if brower == DesiredCapabilities.INTERNETEXPLORER:
#https访问时弹出安全警告页面后点击继续,0代表有安全警告,1代表没有安全警告
driver.get("javascript:document.getElementById('overridelink').click();")
#获取浏览器版本
#brower_name = DesiredCapabilities.INTERNETEXPLORER.get('browserName')
return driver
示例2: remote_open_driver
# 需要导入模块: from selenium.webdriver import Remote [as 别名]
# 或者: from selenium.webdriver.Remote import maximize_window [as 别名]
def remote_open_driver(self,host,brower):
driver = Remote(command_executor=host,
desired_capabilities={'platform':'ANY',
'browserName':brower,
# 'version':'',
'javascriptEnabled':True,
'marionette':False
}
)
ipAdd = jsonTranscoding().get_app_ip().strip()
driver.maximize_window()
driver.get("https://" + ipAdd + "/fort")
if brower == "internet explorer":
#https访问时弹出安全警告页面后点击继续,0代表有安全警告,1代表没有安全警告
driver.get("javascript:document.getElementById('overridelink').click();")
return driver
示例3: selenium_scaner
# 需要导入模块: from selenium.webdriver import Remote [as 别名]
# 或者: from selenium.webdriver.Remote import maximize_window [as 别名]
class selenium_scaner():
links = dict()
current_page = ""
current_submit_button = 0
current_submit_input = 0
def __init__(self):
browser = os.environ.get('TTHA2BROWSER', 'CHROME')
self.driver = Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=getattr(DesiredCapabilities, browser).copy()
)
self.driver.maximize_window()
def check_xss(self):
problems_found = False
problems = self.wait_and_find_many(XSS_SELECTOR)
for i in problems:
problems_found = True
file_logger().trace("Most likely XSS found.\n"+
"Xss script was found in page\n"+
"Outputing page source code to file", LOG_XSS)
file_logger().print_to_file(self.current_page + "\n" + self.driver.page_source + "\n\n")
break
if not problems_found:
if self.driver.page_source.find(XSS_BLOCK) >= 0:
file_logger().trace("Potential XSS found.\n"+
"Xss script was found in page\n"+
"Outputing page source code to file", LOG_XSS)
file_logger().print_to_file(self.current_page + "\n" + self.driver.page_source + "\n\n")
pass
def check_page(self):
self.current_submit_button = -1
self.current_submit_input = -1
inputs_checked = False
submits_checked = False
while ((not inputs_checked) or (not submits_checked)):
text_input_fields = self.wait_and_find_many('input[type="text"]')
password_input_fields = self.wait_and_find_many('input[type="password"]')
text_areas = self.wait_and_find_many('textarea')
submit_inputs = self.wait_and_find_many('input[type="submit"]')
submit_buttons = self.wait_and_find_many('button[type="submit"]')
for i in text_input_fields:
i.send_keys(XSS_BLOCK)
for i in password_input_fields:
i.send_keys(XSS_BLOCK)
for i in text_areas:
i.send_keys(XSS_BLOCK)
inputs_checked = True
for i in submit_inputs:
if i > self.current_submit_input:
self.current_submit_input = i
inputs_checked = False
i.click()
if inputs_checked == True:
submits_checked = True
for i in submit_buttons:
if i >= self.current_submit_button:
self.current_submit_button = i
submits_checked = False
i.click()
self.check_xss()
self.driver.get(self.current_page)
def visit_page(self, target):
found_new_page = False
file_logger().trace("visit " + target, LOG_PROGRESS)
self.current_page = target
self.driver.get(target)
results = self.wait_and_find_many("a[href]")
for i in results:
link = i.get_attribute("href")
if not (link in self.links):
found_new_page = True
self.links[link] = False
self.check_page()
self.links[target] = True
return found_new_page
def scan_site_with_selenium(self, target):
self.target = target
#.........这里部分代码省略.........
示例4: FunctionalTests
# 需要导入模块: from selenium.webdriver import Remote [as 别名]
# 或者: from selenium.webdriver.Remote import maximize_window [as 别名]
class FunctionalTests(unittest.TestCase):
def setUp(self):
browser = os.environ.get('TTHA2BROWSER', 'FIREFOX')
self.driver = Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=getattr(DesiredCapabilities, browser).copy()
)
self.driver.maximize_window()
login(self.driver)
def tearDown(self):
self.driver.quit()
def test_login(self):
create_page = CreatePage(self.driver)
create_page.open()
email = create_page.top_menu.get_email()
self.assertEqual(Constants.USERNAME, email)
def test_income_selected(self):
text_unselected = u'Не учитывать'
text_selected = u'Выбран'
create_page = CreatePage(self.driver)
create_page.open()
settings = create_page.settings
income = settings.income
create_page.hide_menu()
self.assertEqual(text_unselected, income.get_text(), "Неправильный текст в блоке с доходом")
income.toggle()
income.greater.click()
self.assertEqual(text_selected, income.get_text(), "Неправильный текст в блоке с доходом")
income.greater.click()
self.assertEqual(text_unselected, income.get_text(), "Неправильный текст в блоке с доходом")
def test_saving_ages_after_hiding(self):
create_page = CreatePage(self.driver)
create_page.open()
slider = create_page.settings.age
slider.toggle()
create_page.hide_menu()
slider.move_left_slider(100)
slider.move_right_slider(-100)
left, right = slider.get_range()
slider.toggle()
slider.toggle()
self.assertEqual((left, right), slider.get_range(), "Значения после скрытия не совпадают")
def test_saving_income_after_hiding(self):
create_page = CreatePage(self.driver)
create_page.open()
income = create_page.settings.income
income.toggle()
create_page.hide_menu()
income.less.click()
income.greater.click()
income.toggle()
income.toggle()
self.assertEqual((True, False, True), income.get_checked(), "Значения после скрытия не совпадают")
def test_ads_add(self):
create_page = CreatePage(self.driver)
create_page.open()
settings = create_page.base_settings
settings.set_advertising()
settings.set_playground()
settings.set_name("OH MY NAME")
ads_form = create_page.ads_form
ads_form.set_link(Constants.APP)
ads_form.set_title(Constants.TITLE)
ads_form.set_text(Constants.TEXT)
ads_form.set_image(Constants.IMG_PATH)
ads_form.wait_picture()
ads_form.submit()
banner = ads_form.added_banner
self.assertEqual(Constants.TITLE, banner.title.text, "созданный баннер не совпадает с заполненным")
self.assertEqual(Constants.TEXT, banner.text.text, "созданный баннер не совпадает с заполненным")
self.assertIsNotNone(banner.image.value_of_css_property('background-image'), "Картинка не добавилась")
def test_slider(self):
create_page = CreatePage(self.driver)
create_page.open()
settings = create_page.settings
slider = settings.age
slider.toggle()
create_page.hide_menu()
assert slider.left_slider.text not in slider.get_text() and slider.right_slider.text not in slider.get_text()
slider.move_left_slider(100)
assert slider.left_slider.text in slider.get_text() and slider.right_slider.text not in slider.get_text()
slider.move_right_slider(-300)
#.........这里部分代码省略.........
示例5: ExampleTest
# 需要导入模块: from selenium.webdriver import Remote [as 别名]
# 或者: from selenium.webdriver.Remote import maximize_window [as 别名]
class ExampleTest(unittest.TestCase):
def setUp(self):
browser = os.environ.get('TTHA2BROWSER', 'CHROME')
self.driver = Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=getattr(DesiredCapabilities, browser).copy()
)
self.driver.maximize_window()
auth_page = AuthPage(self.driver)
auth_page.open()
auth_page.login()
pass
def tearDown(self):
self.driver.quit()
pass
##done
def testLogin(self):
create_page = CreatePage(self.driver)
create_page.open()
email = create_page.top_menu.getEmail()
self.assertEqual(Vars.Login.USERNAME, email)
pass
##done
def testIncome(self):
create_page = CreatePage(self.driver)
create_page.open()
baseStats = create_page.BaseStats
baseStats.companyProduct.setProductTypeGame()
baseStats.companyTarget.setTargetMyWorld()
baseStats.setCompanyName(Vars.BaseStats.NAME)
create_page.whomBlock.income.lock.open()
create_page.whomBlock.income.low.setChecked()
create_page.whomBlock.income.medium.setChecked()
create_page.whomBlock.income.medium.setUnchecked()
create_page.whomBlock.income.high.setChecked()
create_page.whomBlock.income.lock.close()
create_page.whomBlock.income.lock.open()
self.assertEqual(True, create_page.whomBlock.income.low.getChecked())
self.assertEqual(False, create_page.whomBlock.income.medium.getChecked())
self.assertEqual(True, create_page.whomBlock.income.high.getChecked())
pass
##done
def testCreateBanner(self):
create_page = CreatePage(self.driver)
create_page.open()
baseStats = create_page.BaseStats
baseStats.companyProduct.setProductTypeGame()
baseStats.companyTarget.setTargetMyWorld()
baseStats.setCompanyName(Vars.BaseStats.NAME)
create_page.formBlock.title.setText(Vars.MainStats.TITLE)
create_page.formBlock.text.setText(Vars.MainStats.TEXT)
create_page.formBlock.link.setText(Vars.MainStats.LINK)
create_page.formBlock.imageGrabber.setImage(Vars.MainStats.IMAGE)
WebDriverWait(create_page.formBlock, 30, 0.5).until(checkImage)
create_page.formBlock.submit.click()
self.assertEqual(Vars.MainStats.TITLE, create_page.bannerPreview.title.getText())
self.assertEqual(Vars.MainStats.TEXT, create_page.bannerPreview.text.getText())
self.assertIsNotNone(create_page.bannerPreview.image.getImageUrl())
pass
##done
def testWhenTime(self):
create_page = CreatePage(self.driver)
create_page.open()
baseStats = create_page.BaseStats
baseStats.companyProduct.setProductTypeGame()
baseStats.companyTarget.setTargetMyWorld()
baseStats.setCompanyName(Vars.BaseStats.NAME)
create_page.whenBlock.timeBlock.lock.open()
create_page.whenBlock.timeBlock.workTime.click()
self.assertEqual(Vars.Time.WORK_TIME, create_page.whenBlock.timeBlock.text.getText())
create_page.whenBlock.timeBlock.monday0.open()
self.assertEqual(Vars.Time.HOURS_56, create_page.whenBlock.timeBlock.text.getText())
pass
##done
def testCreateCompany(self):
create_page = CreatePage(self.driver)
create_page.open()
baseStats = create_page.BaseStats
#.........这里部分代码省略.........