Exemplo n.º 1
0
 def callback(elements):
     s = Select(elements.item)
     if i is not None:
         s.deselect_by_index(i)
     elif value is not None:
         s.deselect_by_value(value)
     elif text is not None:
         s.deselect_by_visible_text(text)
     else:
         s.deselect_all()
Exemplo n.º 2
0
def Select_Options():
    select = Select(driver.find_elements_by_id())
    select.select_by_index()
    select.select_by_value()
    select.select_by_visible_text()
    select.deselect_by_index()
    select.deselect_by_value()
    select.deselect_by_visible_text()
    select.deselect_all()

    select.all_selected_options
    select.first_selected_option
    select.options
Exemplo n.º 3
0
def testDeselectByValueMultiple(driver, pages):
    pages.load("formPage.html")
    for select in [multiSelectValues1, multiSelectValues2]:
        sel = Select(driver.find_element(By.NAME, select['name']))
        sel.deselect_all()
        sel.select_by_index(0)
        sel.select_by_index(1)
        sel.select_by_index(2)
        sel.select_by_index(3)
        sel.deselect_by_value(select['values'][1].lower())
        sel.deselect_by_value(select['values'][3].lower())
        selected = sel.all_selected_options
        assert len(selected) == 2
        assert selected[0].text == select['values'][0]
        assert selected[1].text == select['values'][2]
Exemplo n.º 4
0
 def testDeselectByValueMultiple(self):
     if self.driver.capabilities['browserName'] == 'chrome' and int(self.driver.capabilities['version'].split('.')[0]) < 16:
         pytest.skip("deselecting preselected values only works on chrome >= 16")
     self._loadPage("formPage")
     for select in [multiSelectValues1, multiSelectValues2]:
         sel = Select(self.driver.find_element(By.NAME, select['name']))
         sel.deselect_all()
         sel.select_by_index(0)
         sel.select_by_index(1)
         sel.select_by_index(2)
         sel.select_by_index(3)
         sel.deselect_by_value(select['values'][1].lower())
         sel.deselect_by_value(select['values'][3].lower())
         selected = sel.all_selected_options
         self.assertEqual(len(selected), 2)
         self.assertEqual(selected[0].text, select['values'][0])
         self.assertEqual(selected[1].text, select['values'][2])
Exemplo n.º 5
0
 def testDeselectByValueMultiple(self, driver, pages):
     if driver.capabilities['browserName'] == 'chrome' and int(driver.capabilities['version'].split('.')[0]) < 16:
         pytest.skip("deselecting preselected values only works on chrome >= 16")
     pages.load("formPage.html")
     for select in [multiSelectValues1, multiSelectValues2]:
         sel = Select(driver.find_element(By.NAME, select['name']))
         sel.deselect_all()
         sel.select_by_index(0)
         sel.select_by_index(1)
         sel.select_by_index(2)
         sel.select_by_index(3)
         sel.deselect_by_value(select['values'][1].lower())
         sel.deselect_by_value(select['values'][3].lower())
         selected = sel.all_selected_options
         assert len(selected) == 2
         assert selected[0].text == select['values'][0]
         assert selected[1].text == select['values'][2]
Exemplo n.º 6
0
	def test_multiple_selection_in_list(self):
		driver = self.driver
		
	 	#Get the Dropdown as a Select using it's name attribute
 		color = Select(driver.find_element_by_name("color"))
		
		#Verify Dropdown has four options for selection
		self.assertEqual(5,len(color.options))
		
		#Select multiple options in the list using visible text
		color.select_by_visible_text("Black")
		color.select_by_visible_text("Red")
		color.select_by_visible_text("Silver")
		
		#Deselect an option using visible text
		color.deselect_by_visible_text("Silver")
    	
		#Deselect an option using value attribute of the option
		color.deselect_by_value("rd")
		
		#Deselect an option using index of the option
		color.deselect_by_index(0)
Exemplo n.º 7
0
    sys.exit()

checkbox = driver.find_element_by_xpath("/html/body/div/form/p/input")
checkbox.click() # select all genes
# 1. extract leaders
checkbox = driver.find_element_by_xpath("/html/body/div/form/table[2]/tbody/tr[2]/td[3]/input[1]")
checkbox.click() 
set_option(driver, "selectedLabels", "L-PART1+L-PART2")
submit_button = driver.find_element_by_xpath("/html/body/div/form/input")
submit_button.click() # submit query
print("Retrieved leaders successfully :-)")
# store data
output_handle = open(leader_file, "w")
template_info = driver.find_element_by_xpath("/html/body/pre[2]").text # extract content from second <pre>
output_handle.write(template_info)
output_handle.close()
# 2. extract leader + variable region (L-PART1 + L-PART2 is extracted, although label says something different) + exon
driver.back()  # go back to previous browser page
# clear previous region selection and select new region
element = Select(driver.find_element_by_name("selectedLabels"))
element.deselect_by_value("L-PART1+L-PART2") 
set_option(driver, "selectedLabels", "L-PART1+V-EXON")
submit_button = driver.find_element_by_xpath("/html/body/div/form/input") # update submit button
submit_button.click() # submit query
print("Retrieved exons successfully :-)")
# store data
output_handle = open(exon_file, "w")
template_info = driver.find_element_by_xpath("/html/body/pre[2]").text # extract content from second <pre>
output_handle.write(template_info)
output_handle.close()
Exemplo n.º 8
0
                print(Fore.LIGHTGREEN_EX + 'Logged sucessful.')
        except:
            print(Fore.GREEN + 'Already authenticated.')

        print(Fore.YELLOW + "Completing Search Fields...")
        print(Fore.GREEN + Style.BRIGHT + 'Search Parameters:\n' +
              "................... Peaklist: " + str(peaklist) + '\n' +
              "................... Taxonomy: " +
              Taxonomy.replace('.', '').strip() + '\n' +
              "................... Database: " + Database + '\n' +
              "................... PepTol  : " + pepComb[1] + " " +
              pepComb[0] + '\n')

        data_Base_Select = Select(driver.find_element_by_name('DB'))
        data_Base_Select.select_by_value(Database)
        data_Base_Select.deselect_by_value('Gossypium_hirsutum')

        taxonomy_Select = Select(driver.find_element_by_name('TAXONOMY'))
        taxonomy_Select.select_by_value(Taxonomy)

        miss_Cleavages = Select(driver.find_element_by_name('PFA'))
        miss_Cleavages.select_by_value(str(Missed_cleavages))

        Mods_Select = Select(driver.find_element_by_name('MASTER_MODS'))
        Mods_Select.select_by_value('Carbamidomethyl (C)')
        driver.find_element_by_name('add_MODS').click()
        Mods_Select.select_by_value('Oxidation (M)')
        driver.find_element_by_name('add_IT_MODS').click()

        unity_Select = Select(driver.find_element_by_name('TOLU'))
        unity_Select.select_by_value(pepComb[0])
Exemplo n.º 9
0
    def select_option(self, obj):
        # Set local parameters
        step = obj.get('order')
        identifier_dict = obj.get('identifier')
        if identifier_dict is None:
            raise Exception('No identifier')
        child_window = obj.get('child_window')
        if child_window is None:
            raise Exception('No child_window')
        selection_value = obj.get('selection_value')
        if selection_value is None:
            raise Exception('No selection_value')
        selection_type = obj.get('selection_type')
        if selection_type is None:
            raise Exception('No selection_type')
        multiline = obj.get('multiline')
        action = None

        element = self.ei.uniquely_identify_element(identifier_dict)

        # Report no element found
        if element is None:
            action = 'No element found'
            return action

        if element is not None:

            # Prepare element for action
            self.__wait_for_post_back_to_complete(element, obj.get('timeout'))
            self.driver.execute_script('return arguments[0].scrollIntoView();', element)
            self.driver.execute_script(' window.scrollBy(0, -100);')
            selection = Select(element)
            options = selection.options
            acted_upon_options = self.__determine_acted_upon_option(options, selection_value, selection_type)

            # Determine how we are interacting with the select
            if selection_type.lower() == "index":
                action = "Select '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.select_by_index(selection_value)
            elif selection_type.lower() == "text":
                action = "Select '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.select_by_visible_text(selection_value)
            elif selection_type.lower() == "value":
                action = "Select '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.select_by_value(selection_value)
            elif selection_type.lower() == "deindex":
                action = "Deselect '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.deselect_by_index(selection_value)
            elif selection_type.lower() == "detext":
                action = "Deselect '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.deselect_by_visible_text(selection_value)
            elif selection_type.lower() == "devalue":
                action = "Deselect '" + acted_upon_options + "' from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.deselect_by_value(selection_value)
            elif selection_type.lower == "deall":
                action = "Deselected all values from the '" + str(
                    self.find_html_for(element.get_attribute('id'))) + "' dropdown"
                selection.deselect_all()
            else:
                # This should really just be reported and not raise an exception
                raise Exception("Unknown selection type.")

        # Determine if action changes browser count
        if child_window:
            self.change_window_connection()

        print(action)
        return action