def _pay(self): bitcoinAmount = self.driver.find_element_by_css_selector(".ng-binding.payment__details__instruction__btc-amount").text toWallet = self.driver.find_element_by_css_selector(".payment__details__instruction__btc-address.ng-binding").text print("amount: " + bitcoinAmount) print("to wallet: " + toWallet) wallet = Wallet() return wallet.payToAutomatically(toWallet, bitcoinAmount)
def _pay(self): """Extract the invoice information and pay for the VPS""" bitcoinAmount = self.driver.find_element_by_css_selector(".ng-binding.payment__details__instruction__btc-amount").text toWallet = self.driver.find_element_by_css_selector(".payment__details__instruction__btc-address.ng-binding").text print("Bitcoin amount to transfer: " + bitcoinAmount) print("To wallet: " + toWallet) wallet = Wallet() return wallet.payToAutomatically(toWallet, bitcoinAmount)
def _pay(self): self.driver.switch_to_frame(self.driver.find_element_by_tag_name("iframe")) text = self.driver.find_element_by_tag_name('body').text lines = text.split('\n') firstlinesplit = lines[0].split(' ') bitcoinAmount = firstlinesplit[2] toWallet = lines[2] self.pay_page_url = self.driver.current_url print("amount: " + bitcoinAmount) print("to wallet: " + toWallet) wallet = Wallet() return wallet.payToAutomatically(toWallet, bitcoinAmount)
def _pay(self): self.driver.find_element_by_css_selector("input[type='submit'][value='Pay Now']").click() self.driver.implicitly_wait(10) bitcoinAmount = self.driver.find_element_by_css_selector(".ng-binding.payment__details__instruction__btc-amount").text toWallet = self.driver.find_element_by_css_selector(".payment__details__instruction__btc-address.ng-binding").text print("Bitcoin amount to transfer: " + bitcoinAmount) print("To wallet: " + toWallet) print("Email used: " + self.email) print("Password used: " + self.password) print("SSHPassword to be used: " + self.SSHPassword) print("SSHUsername to be used: " + self.SSHUsername) wallet = Wallet() return wallet.payToAutomatically(toWallet, bitcoinAmount)
def placeOrder(self): """ Places an order on THCServers for a new VPS. """ try: self.spawnBrowser() self.driver.get("https://www.thcservers.com/vps-hosting") self.driver.find_element_by_class_name("vps_submit_form").click() self.fillInElement("hostname", self.generator.getRAString(10)) self.fillInElement("ns1prefix", "ns1") self.fillInElement("ns2prefix", "ns2") self.fillInElement("rootpw", self.SSHPassword) # configoption[9] #self.chooseSelectElement("configoption[5]", "Ubuntu 14.04") self.driver.execute_script("var elements = document.getElementsByName('configoption[5]'); var element = elements[0]; element.value = '87'; recalctotals();") self.driver.implicitly_wait(2) self.driver.find_element_by_class_name("checkout").click() self.driver.implicitly_wait(10) self.fillInElement('firstname', self.generator.getFirstName()) self.fillInElement('lastname', self.generator.getSurname()) self.fillInElement('email', self.email) self.fillInElement('address1', self.generator.getRAString(randint(8, 15)) + ' ' + self.generator.getRNString(randint(1, 2))) self.fillInElement('city', self.generator.getCity()) self.fillInElement('postcode', self.generator.getZipcode()) # country self.driver.execute_script("var element = document.getElementById('country'); element.value = 'US';") self.driver.execute_script("document.getElementById('stateselect').value = 'Kansas';") self.fillInElement('phonenumber', self.generator.getPhoneNum()) # password = # Generate a password self.driver.find_element_by_id("newpw").send_keys(self.password) #self.fillInElement('password', self.password) self.fillInElement('password2', self.password) self.driver.find_element_by_id('pgbtnbitpay').click() self.driver.find_element_by_name('accepttos').click() print("Email used: " + self.email) print("password used: " + self.password) self.driver.find_element_by_css_selector('.btn.btn-success').click() try: self.driver.find_element_by_css_selector('input[value="Pay Now"]').click() except Exception as e: print("Warning: Pay now button not found") bitcoinAmount = self.driver.find_element_by_css_selector(".ng-binding.payment__details__instruction__btc-amount").text toWallet = self.driver.find_element_by_css_selector(".payment__details__instruction__btc-address.ng-binding").text print("amount: " + bitcoinAmount) print("to wallet: " + toWallet) print("password: "******"email: " + self.email) wallet = Wallet() paymentSucceeded = wallet.payToAutomatically(toWallet, bitcoinAmount) if paymentSucceeded == False: return False # Wait for the transaction to be accepted wait = ui.WebDriverWait(self.driver, 666) wait.until(lambda driver: driver.find_element_by_css_selector('.payment--paid')) self.closeBrowser() except WebDriverException as e: print("Could not complete the transaction because an error occurred:") print("WebDriverException") print(e.msg) self.closeBrowser() return False except Exception as e: print("Could not complete the transaction because an error occurred:") print(unicode(e, "utf-8")) self.closeBrowser() return False #raise # Raise the exception that brought you here return True