Esempio n. 1
0
    def get_search_result(self):

        rcf = ReadConfigFile()
        brow_url = rcf.get_value()
        browsertype = brow_url[0]
        browserurl = brow_url[1]
        print browsertype, browserurl

        browserengine = BrowserEngine(self)
        driver = browserengine.get_browser()

        basepage = BasePage(driver)
        basepage.open_url(browserurl)

        driver.find_element_by_id('kw').send_keys('selenium')
        time.sleep(1)
        search_result_string = driver.find_element_by_xpath(
            "//span[@class='nums_text']").text
        print(search_result_string)

        new_string = search_result_string.split(u'约')[
            1]  #第一次切割得到  xxxx个, [1]代表切割右边部分
        print(new_string)
        last_result = new_string.split(u'个')[0]  #第二次切割,得到想要的数字 [0]代表切割参照数的左边部分
        print(last_result)
Esempio n. 2
0
    def generate_game(self):
        """Generate the game using the complexity level chosen.

        list get_level_details --> ['Easy',70,60,'Active']. Level details set in the configuration file
        get_level_details[0] --> level name
        get_level_details[1] --> top limit
        get_level_details[2] --> bottom limit
        get_level_details[3] --> status
        """
        get_level_active_name = ReadConfigFile(
            self.file_config).get_list_of_generation_levels_names()
        get_level_details = ReadConfigFile(
            self.file_config).get_details_of_generation_levels(
                get_level_active_name[0])
        print get_level_details
Esempio n. 3
0
    def test_every_level_should_have_bottom_and_top_values(self):
        level_name = 'Easy'
        details_level = [level_name, '60', '70', 'Active']

        get_data = ReadConfigFile(
            config_test).get_details_of_generation_levels(level_name)
        self.assertEqual(details_level, get_data)
Esempio n. 4
0
    def save_game(self):
        """Save the game results in a file.

        string file_path --> 'c:\sudoku\sudoku.txt'. File path set in the configuration file
        """
        get_output_file = ReadConfigFile(self.file_config).get_output_file()
        file_path = get_output_file[0] + '\\' + get_output_file[1]
        print file_path
Esempio n. 5
0
    def solve_game(self):
        """Return the game solved using the algorithm chosen.

        string get_active_algorithm --> 'Backtracking'. algorithm set in the configuration file
        """
        get_algorithms = ReadConfigFile(
            self.file_config).get_list_of_algorithms()
        get_active_algorithm = get_algorithms[0]
        print get_active_algorithm
Esempio n. 6
0
    def show_level_combobox(self):
        """Show the levels read from configuration file in the combobox."""

        lst_values_level = ReadConfigFile(
            self.file_config).get_list_of_generation_levels_names()
        levels_combo = ttk.Combobox(self.main, state='readonly')
        levels_combo['values'] = (lst_values_level)
        levels_combo.current(0)
        levels_combo.place(x=100, y=230)

        self.show_details_of_level(lst_values_level[0])
Esempio n. 7
0
    def show_list_algorithms(self):
        """Show the algorithms read from configuration file in a combolist."""

        list_of_algorithms = ReadConfigFile(
            self.file_config).get_list_of_algorithms()

        algorithms_listbox = Listbox(self.main, heigh=4)

        for index in range(len(list_of_algorithms)):
            algorithms_listbox.insert(index, list_of_algorithms[index])

        algorithms_listbox.selection_set(first=0)
        algorithms_listbox.place(x=100, y=130)
Esempio n. 8
0
    def show_details_of_level(self, level_name):
        """Show the top, botton values of a specific level.

        string level_name --> ('Easy')
        """
        details_level = ReadConfigFile(
            self.file_config).get_details_of_generation_levels(level_name)
        top_limit = StringVar()
        botton_limit = StringVar()
        top_limit.set(details_level[1])
        botton_limit.set(details_level[2])
        top_limit = Entry(self.main, textvariable=top_limit).place(x=100,
                                                                   y=260)
        botton_limit = Entry(self.main, textvariable=botton_limit).place(x=100,
                                                                         y=290)
Esempio n. 9
0
    def fill_values_in_the_output_file_entry(self, custom_path=None):
        """Fill Output file path box.

        string get_values_output_file --> ('c:\sudoku\sudoku.txt') it gets the value returned of get_output_file function from "readconfigfile" class. """
        get_values_output_file = ReadConfigFile(
            self.file_config).get_output_file()
        current_path = StringVar()
        current_file_name = StringVar()
        if custom_path == None:
            current_path.set(get_values_output_file[0] + '\\' +
                             get_values_output_file[1])
        else:
            current_path.set(custom_path)

        output_file = Entry(self.main, textvariable=current_path,
                            width=50).place(x=100, y=40)
Esempio n. 10
0
 def test_default_values_of_config_file(self):
     get_data = ReadConfigFile(config_test).get_output_file()
     default_values = get_data[0] + "\\" + get_data[1]
     self.assertEqual("d:\SudokuGame\Sudoku.txt", default_values)
Esempio n. 11
0
 def test_one_level_option_should_be_set_as_active(self):
     get_data = ReadConfigFile(
         config_test).get_list_of_generation_levels_names()
     self.assertEqual("Easy", get_data[0])
Esempio n. 12
0
 def test_one_algorithm_should_be_set_as_active(self):
     get_data = ReadConfigFile(config_test).get_list_of_algorithms()
     default_algorithm = "Peter Novig" + "\'" + "s"
     self.assertEqual(default_algorithm, get_data[0])