def prep(self): if not self.ifc: o = self.options self.ifc = SeleniumInterface(executor='http://%s:4444/wd/hub' % o.selenium, browser='htmlunit', platform='ANY') self.ifc.open() self._ourifc = True
def prep(self): if not self.ifc: o = self.options if ':' not in o.selenium: o.selenium = '%s:4444' % o.selenium self.ifc = SeleniumInterface(executor='http://%s/wd/hub' % o.selenium, browser='chrome', platform='ANY') self.ifc.open() self._ourifc = True
class LicenseGenerator(Macro): def __init__(self, options, ifc=None): self.options = Options(options) self.ifc = ifc self._ourifc = False super(LicenseGenerator, self).__init__() def prep(self): if not self.ifc: o = self.options if ':' not in o.selenium: o.selenium = '%s:4444' % o.selenium self.ifc = SeleniumInterface(executor='http://%s/wd/hub' % o.selenium, browser='chrome', platform='ANY') self.ifc.open() self._ourifc = True def cleanup(self): if self._ourifc: self.ifc.close() def setup(self): options = self.options b = self.ifc.api root = MAP.eval if self.options.eval else MAP.dev if self.options.bigip: productline = 'BIG-IP' product = root.bigip.get(options.bigip) if not product: pprint.pprint(root.bigip) raise ValueError("Only BIGIP %s are supported." % root.bigip.keys()) elif self.options.em: productline = 'EM' product = root.em.get(options.em) if not product: pprint.pprint(root.em) raise ValueError("Only EM %s are supported." % root.em.keys()) elif self.options.bigiq: productline = 'BIG-IQ' product = root.bigiq.get(options.bigiq) if not product: raise ValueError("Only BIGIQ %s are supported." % root.bigiq.keys()) else: raise ValueError("Only BIGIP, EM or BIGIQ are supported.") if self.options.eval: b.get('https://license/evalkeygenerator/') else: b.get('https://license/devkeygenerator/') LOG.info('Logging in...') e = b.find_element_by_name('user') e.send_keys(options.username) e = b.find_element_by_name('pass') e.send_keys(options.password) e = b.find_element_by_name('submit_form') select = e.click().wait('productline') LOG.info('SKU %s', product) LOG.info('Selecting product...') o = select.find_element_by_xpath("option[.='%s']" % productline) o.click() select = b.find_element_by_id('product') o = select.find_element_by_xpath("option[.='%s']" % product) o.click() if not self.options.eval: e = b.find_element_by_name('notes') e.send_keys('Generated using f5.licensegen v%s tool.' % __version__) e = b.find_element_by_name('eula_agree') e.click() button = b.find_element_by_id('nextBtn') table = button.click().wait('evalKeyTable') LOG.info('Selecting modules...') for e in table.find_elements_by_xpath("//tr/td[@class='productFont' " "and img[@src='images/assets/notSelectedBox.gif']]"): text = e.text.strip() if text.startswith('APM') or text.startswith('Access Policy Manager'): if not 'Base' in text: continue LOG.info(" %s", text) img = e.find_element_by_tag_name('img') img.click() LOG.info('Selecting features...') for e in table.find_elements_by_xpath("//tr/td[@class!='productFont' " "and img[@src='images/assets/notSelectedBox.gif']]"): text = e.text.strip() for label in BANNED_FEATURES: banned = False if text.find(label) >= 0: banned = True break if not banned: LOG.info(" %s", text) img = e.find_element_by_tag_name('img') img.click() LOG.info('Selecting radio buttons...') # This xpath selects every last radio button from each "Multiple Options" group. xpath = "//tr[td[@class='availRadioFont'] and following-sibling::tr[position()=1 and td[not(@class) or @class!='availRadioFont']]]" for e in table.find_elements_by_xpath(xpath): text = e.text.strip() for label in BANNED_FEATURES: banned = False if text.find(label) >= 0: banned = True break if not banned: LOG.info(" %s", text) img = e.find_element_by_tag_name('img') img.click() e = b.find_element_by_name('copier') e.clear() e.send_keys(str(options.count)) button = table.find_element_by_css_selector("input[type=submit]") button.click().wait("//h1[.='SUCCESS - REQUEST PROCESSED']", by=By.XPATH) LOG.info('Done! You should receive an email shortly.')
class LicenseGenerator(Macro): def __init__(self, options, ifc=None): self.options = Options(options) self.ifc = ifc self._ourifc = False super(LicenseGenerator, self).__init__() def prep(self): if not self.ifc: o = self.options self.ifc = SeleniumInterface(executor='http://%s:4444/wd/hub' % o.selenium, browser='htmlunit', platform='ANY') self.ifc.open() self._ourifc = True def cleanup(self): if self._ourifc: self.ifc.close() def setup(self): options = self.options b = self.ifc.api root = MAP.eval if self.options.eval else MAP.dev if self.options.bigip: productline = 'BIG-IP' product = root.bigip.get(options.bigip) if not product: pprint.pprint(root.bigip) raise ValueError("Only BIGIP %s are supported." % root.bigip.keys()) elif self.options.em: productline = 'EM' product = root.em.get(options.em) if not product: pprint.pprint(root.em) raise ValueError("Only EM %s are supported." % root.em.keys()) elif self.options.bigiq: productline = 'BIG-IQ' product = root.bigiq.get(options.bigiq) if not product: raise ValueError("Only BIGIQ %s are supported." % root.bigiq.keys()) else: raise ValueError("Only BIGIP, EM or BIGIQ are supported.") if self.options.eval: b.get('https://license.f5net.com/evalkeygenerator/') else: b.get('https://license.f5net.com/devkeygenerator/') LOG.info('Logging in...') e = b.find_element_by_name('user') e.send_keys(options.username) e = b.find_element_by_name('pass') e.send_keys(options.password) e = b.find_element_by_name('submit_form') select = e.click().wait('productline') LOG.info('SKU %s', product) LOG.info('Selecting product...') o = select.find_element_by_xpath("option[.='%s']" % productline) o.click() select = b.find_element_by_id('product') o = select.find_element_by_xpath("option[.='%s']" % product) o.click() if not self.options.eval: e = b.find_element_by_name('notes') e.send_keys('Generated using f5.licensegen v%s tool.' % __version__) e = b.find_element_by_name('eula_agree') e.click() button = b.find_element_by_id('nextBtn') table = button.click().wait('evalKeyTable') LOG.info('Selecting modules...') for e in table.find_elements_by_xpath("//tr/td[@class='productFont' " "and img[@src='images/assets/notSelectedBox.gif']]"): text = e.text.strip() if text.startswith('APM') or text.startswith('Access Policy Manager'): if not 'Base' in text: continue LOG.info(" %s", text) img = e.find_element_by_tag_name('img') img.click() LOG.info('Selecting features...') for e in table.find_elements_by_xpath("//tr/td[@class!='productFont' " "and img[@src='images/assets/notSelectedBox.gif']]"): text = e.text.strip() for label in BANNED_FEATURES: banned = False if text.find(label) >= 0: banned = True break if not banned: LOG.info(" %s", text) img = e.find_element_by_tag_name('img') img.click() LOG.info('Selecting radio buttons...') # This xpath selects every last radio button from each "Multiple Options" group. xpath = "//tr[td[@class='availRadioFont'] and following-sibling::tr[position()=1 and td[not(@class) or @class!='availRadioFont']]]" for e in table.find_elements_by_xpath(xpath): text = e.text.strip() for label in BANNED_FEATURES: banned = False if text.find(label) >= 0: banned = True break if not banned: LOG.info(" %s", text) img = e.find_element_by_tag_name('img') img.click() e = b.find_element_by_name('copier') e.clear() e.send_keys(str(options.count)) button = table.find_element_by_css_selector("input[type=submit]") button.click().wait("//h1[.='SUCCESS - REQUEST PROCESSED']", by=By.XPATH) LOG.info('Done! You should receive an email shortly.')