Exemplo n.º 1
0
    def test_kill_and_run_process_by_name(self):
        warnings.simplefilter('ignore', ResourceWarning)
        WindowsOsUtil.run_process_by_name(self.processToTestRunAndKill)
        self.assertTrue(WindowsOsUtil.check_process_running(self.processToTestRunAndKill))

        WindowsOsUtil.kill_process_by_name(self.processToTestRunAndKill)
        self.assertFalse(WindowsOsUtil.check_process_running(self.processToTestRunAndKill))
    def test_kill_and_run_process_by_name(self):
        WindowsOsUtil.run_process_by_name(self.processToTestRunAndKill)
        assert WindowsOsUtil.check_process_running(
            self.processToTestRunAndKill)

        WindowsOsUtil.kill_process_by_name(self.processToTestRunAndKill)
        assert not WindowsOsUtil.check_process_running(
            self.processToTestRunAndKill)
 def setup_params(self):
     self.processIsRunning = 'python.exe'
     self.processNotRunning = 'retroarch.exe'
     self.processToTestRunAndKill = 'notepad.exe'
     self.command = 'echo 123'
     yield
     if WindowsOsUtil.check_process_running(self.processToTestRunAndKill):
         WindowsOsUtil.kill_process_by_name(self.processToTestRunAndKill)
Exemplo n.º 4
0
 def tearDownClass(cls):
     if WindowsOsUtil.check_process_running(cls.processToTestRunAndKill):
         WindowsOsUtil.kill_process_by_name(cls.processToTestRunAndKill)
Exemplo n.º 5
0
from selenium.common.exceptions import NoAlertPresentException
from selenium.common.exceptions import TimeoutException
from file_and_system.file_utils import write_binary_to_file
from file_and_system.windows_os_utils import WindowsOsUtil
from python_common.global_param import GlobalParam
from selenium_test.selenium_utils import *

WindowsOsUtil.kill_process_by_name('MicrosoftWebDriver.exe')
driver = init_driver('edge', GlobalParam.get_edge_driver_path())
open_browser_single_tab(driver, 'https://www.12306.cn/index/')

# wait dom return complete state
wait_for_page_full_loaded(driver)
loading_element = find_element_by_xpath(driver, '//div[@id="page-loading"]')
wait_for_element_disappeared(driver, loading_element)
try:

    wait_for_element_to_be_clickable(driver, '//a[text()="登录"]')
    wait_for_page_full_loaded(driver)
    wait_for_element_to_be_clickable(driver, '//a[text()="账号登录"]')

    # get captcha picture
    img_text = find_element_by_xpath(driver,
                                     '//img[@id="J-loginImg"]').get_attribute(
                                         'src')[len('data:image/jpg;base64,'):]
    write_binary_to_file(GlobalParam.get_image_input(), img_text)

    find_element_by_xpath(driver,
                          '//input[@id="J-userName"]').send_keys('username')
    find_element_by_xpath(driver,
                          '//input[@id="J-password"]').send_keys('password')
from file_and_system.windows_os_utils import WindowsOsUtil
from selenium_test.selenium_utils import init_driver, open_browser_single_tab
from python_common.global_param import GlobalParam

WindowsOsUtil.kill_process_by_name('MicrosoftWebDriver.exe')
WindowsOsUtil.kill_process_by_name('chromedriver.exe')
WindowsOsUtil.kill_process_by_name('IEDriverServer.exe')
chrome_driver = init_driver('chrome', GlobalParam.get_chrome_driver_path())
open_browser_single_tab(chrome_driver,'https://www.baidu.com')
chrome_driver.quit()

edge_driver = init_driver('edge', GlobalParam.get_edge_driver_path())
open_browser_single_tab(edge_driver,'https://www.baidu.com')
edge_driver.quit()

ie_driver = init_driver('ie', GlobalParam.get_ie_driver_path())
open_browser_single_tab(ie_driver,'https://www.baidu.com')
ie_driver.quit()