class Login(): def __init__(self): self.browser = {} @keyword def open_browser(self, name='chrome'): self.browser = Browser(browser=name) @keyword def open_on_sauce(self): caps = { 'platformName': 'Windows 10', 'plaformVersion': 'latest', 'browserName': 'chrome' } username = environ.get('SAUCE_USERNAME', None) access_key = environ.get('SAUCE_ACCESS_KEY', None) selenium_endpoint = "http://ondemand.saucelabs.com/wd/hub" caps['username'] = username caps['accesskey'] = access_key caps['name'] = 'Robot Nerodia - Login' executor = RemoteConnection(selenium_endpoint, resolve_ip=False) remote = webdriver.Remote(command_executor=executor, desired_capabilities=caps) self.browser = Browser(browser=remote, desired_capabilities=caps) @keyword def go_to_login(self): self.browser.goto(BASE_TEST_URL + "login") @keyword def login_as(self, username, password): self.browser.input(id='username').send_keys(username) self.browser.input(id='password').send_keys(password) self.browser.button(class_name='radius').click() @keyword def is_error_message_visible(self): assert self.browser.element(class_name='error').present @keyword def is_login_successful(self): assert self.browser.element(class_name='success').present @keyword def close_browser(self): self.browser.quit()
#!/usr/bin/env python3 from nerodia.browser import Browser import re loginsite = "https://mggym-borken.lms.schulon.org/login/index.php" browser = Browser(browser='firefox') browser.goto(loginsite) usrn = browser.text_field(name="username") usrn.value = '' pswd = browser.text_field(name="password") pswd.value = '' browser.button(value='Login').click() html = browser.html #print(html:=browser.html) matches = re.findall( '<span.*>Meine Kurse<\/span>.*href="(https:\/\/mggym-borken.lms.schulon.org\/course\/view.php\?id=\d+)">.*href="(https:\/\/mggym-borken.lms.schulon.org\/course\/view.php\?id=\d+)">.*href="(https:\/\/mggym-borken.lms.schulon.org\/course\/view.php\?id=\d+)">', html) kurse = list(matches[0]) #print(kurse) for kurs in kurse: browser.goto(kurs) html = browser.html matches = re.findall( 'href="(https:\/\/mggym-borken\.lms\.schulon\.org\/mod\/resource\/view.php\?id=\d+)"><img src="https:\/\/mggym-borken\.lms\.schulon\.org\/theme\/image\.php\/classic\/core\/1587401819\/f\/pdf-24"', html) print(matches)
from time import sleep # needed to perform sleep from faker import Faker # needed for fake form data import os # needed for file path # Setup browser = Browser(browser='chrome') browser.window().maximize() # Navigate to the Page browser.goto('a.testaddressbook.com') # Authenticate and Navigate to the Form browser.link(id='sign-in').click() browser.text_field(data_test='email').set('*****@*****.**') browser.text_field(data_test='password').set('password') browser.button(name='commit').click() browser.link(data_test='addresses').click() browser.link(data_test='create').click() # This uses the Faker Library to give us Random Data. # Read more about Faker Library here: https://pypi.org/project/Faker/ fake = Faker() # So we can use fake.name() instead of Faker().name() browser.text_field(id='address_first_name').set(fake.first_name()) browser.text_field(id='address_last_name').set(fake.last_name()) browser.text_field(id='address_street_address').set(fake.street_address()) browser.text_field(id='address_secondary_address').set( fake.secondary_address()) browser.text_field(id='address_city').set(fake.city()) # Select list elements can select by either `text` or `value`
from nerodia.browser import Browser browser = Browser(browser='chrome') browser.goto( 'http://wp.curve.in.th/wp-login.php?loggedout=true&wp_lang=en_US&jetpack-sso-show-default-form=1' ) t = browser.text_field(id='user_login') t.value = '**' t = browser.text_field(id='user_pass') t.value = '***' browser.button(id='wp-submit').click() browser.wait_until(timeout=2, interval=0.5, method=lambda e: e.title.startswith("Dashboard")) posts = [] for i in range(1, 6): browser.goto(f'http://wp.curve.in.th/wp-admin/edit.php?paged={i}') for t in browser.trs(class_name="type-post"): p = {} date = t.td(class_name="date").span().text date = date.replace("/", "-") p["date"] = date link = t.div(class_name="row-actions").span( class_name="view").link().href p["view_link"] = link p["name"] = link.replace("http://wp.curve.in.th/", "")
BASE = "https://herdt-campus.com" fp = webdriver.FirefoxProfile('/home/bf/.mozilla/firefox/a67xxtyb.auto') driver = webdriver.Firefox(fp) #browser = Browser(browser='firefox') browser = Browser(driver) browser.goto('https://bk-ostvest.lms.schulon.org/mod/url/view.php?id=16833') usrn = browser.text_field(name='username') usrn.value = '' pswd = browser.text_field(name='password') pswd.value = '' browser.button(value='Login').click() browser.button(value='Ich stimme zu!').click() katalog = re.findall( r'<a class="catalog-nav-link" href="(\/category\/herdt-themen\/[\w\/\- ]*)">[\w\/\- ]*<\/a>', browser.html) categorieDict = dict() for category in katalog: #browser.goto(category) site = 0 dic = dict()
from nerodia.browser import Browser browser = Browser(browser='firefox') browser.goto('https://myonlineportal.net/') usrn = browser.text_field(name='username') usrn.value = '' pswd = browser.text_field(name='password') pswd.value = '' browser.button(value='Login').click() browser.goto('https://myonlineportal.net/extend_account') browser.button(value='Account verlängern!').click()
class Bot(Thread): def __init__(self, candidate, url, *args, **kwargs): super().__init__(*args, **kwargs) self.email = config('email') self.password = config('password') self.candidate = candidate self._running = False self.url = url self.browser = None self.open() def __exit__(self, exc_type, exc_val, exc_tb): self.close() def open(self): print('abrindo browser') self.browser = Browser('firefox') self.browser.goto(self.url) self.browser.wait() def close(self): print('fechando browser') self.browser.close() def auth(self): self.condidate_div.click() # IFRAME MALDITO! # with self.browser.windows[1] # self.browser. # login = self.browser.input(id='login') # login.wait_for_present() # login.send_keys(self.email) # # password = self.browser.input(id='password') # password.wait_for_present() # password.send_keys(self.password) # # entrar = self.browser.button(text='Entrar') # entrar.wait_for_present() # entrar.click() @property def condidate_div(self): return self.browser.div(text=self.candidate) @property def captcha_div(self): return self.browser.div(class_name=[ '_3xDixtS9TduMA-tXdgvxyM', '_2DsRxsoPgkhrq5exq-TSVO', '_2cZtCsRea_lK2Xi3dqwru' ]) def votar_novamente(self): button = self.browser.button(text='Votar Novamente') if button.present: print('vou votar novamente!') button.click() sleep(2) def votar(self): candidate = self.condidate_div if candidate.present: print('candidato presente!') candidate.click() sleep(2) while candidate.present: captcha_div = self.captcha_div captcha_div.wait_for_exists() print('Achei o captcha!') img = captcha_div.img() print('Vou clickar!') img.click() sleep(5) def run(self): # self.open_browser() # self.auth() self._running = True while self._running: try: self.votar() self.votar_novamente() except Exception as e: pass self.browser.close()
def main(): global browserTwitter, browserNewEgg, username, password, driver, options, rtxCardLink options.add_argument("--log-level=3") time.sleep(2) print("...") time.sleep(3) #start up text clear_console(5) print("Welcome to the RTX Bot Script!") clear_console(1) print("To begin, enter your username and password") print("to access your personal information") clear_console(5) #logs user in to retrieve personal information login() time.sleep(2) print("...") time.sleep(3) print("User successfully logged in!") #loads personal infrormation using password as key for decryption loadPersonalInformation() time.sleep(2) print("...") time.sleep(1) print("Personal Information Loaded!") time.sleep(2) print("...") time.sleep(3) print("Loading vpn...") ''' vpnStart() time.sleep(12) ''' print("Connected to VPN!") print("...") time.sleep(3) print("Loading browser to newegg...") time.sleep(2) driver = webdriver.Chrome(options=options) browserNewEgg = Browser(browser=driver) time.sleep(4) browserNewEgg.goto(rtxCardLink) wait(1) #clears browser cache browserNewEgg.cookies.clear() wait(9) #closes pop up if (browserNewEgg.link(id='popup-close').exists): browserNewEgg.link(id='popup-close').click() print("All set! Refreshing newegg until they restock") x = datetime.datetime.now() y = x + datetime.timedelta(seconds=120) #checks newegg until restock restocked = False count = 0 while restocked == False: if (count > 40): count = 0 time.sleep(1) print("Restarting browser with new IP...") #clears browser cache browserNewEgg.cookies.clear() time.sleep(1) #closes browser browserNewEgg.close() time.sleep(1) #disconnect from vpn vpnEnd() time.sleep(10) #reconnects to vpn vpnStart() time.sleep(12) driver = webdriver.Chrome(options=options) browserNewEgg = Browser(browser=driver) time.sleep(1) browserNewEgg.goto(rtxCardLink) time.sleep(12) #closes pop up if (browserNewEgg.link(id='popup-close').exists): browserNewEgg.link(id='popup-close').click() wait(2) else: pass browserNewEgg.refresh() wait(3) locator = {"class": "nav-col", "index": 1} condition = (browserNewEgg.div(class_name="product-buy").div().div( **locator).button()).exists x = datetime.datetime.now() condition = x > y if (condition): restocked = True else: pass count += 1 clear_console(100) print("Cards restocked!") time.sleep(1) #clicks add to cart browserNewEgg.div(class_name="product-buy").div().div( **locator).button().click() time.sleep(2) #declines warrenty if it is presented if (not (browserNewEgg.div(class_name="item-summary").exists)): locator = {"index": 0} browserNewEgg.div(class_name="modal-footer").button(**locator).click() time.sleep(2) #clicks view cart and checkout browserNewEgg.button(title="View Cart & Checkout").click() wait(5) #says no to masks if asked if (browserNewEgg.button(id="Masks_addtocart").exists): locator = {"index": 0} locator2 = {"index": 1} browserNewEgg.div(class_name="modal-footer").div(**locator2).button( **locator).click() time.sleep(2) #goes to secure checkout browserNewEgg.div(class_name="summary-actions").button().click()
text3 = browser.element( text= "Always click on the ads display at the right side, this is how we manage the website’s expenses and bring free content for the beginners." ) print(text3.text) browser.link(text="Partial Link Test").wait_until_present().click() browser.link(text="Link Test").wait_until_present().click() browser.back() browser.text_field(name="firstname").wait_until_present().set("Fname") browser.text_field(name="firstname").clear() browser.select_list(id="continents").select("Antartica") browser.select_list(id="selenium_commands").select("Switch Commands") browser.button(id="submit") browser.radio(id="sex-0").set() browser.radio(id="sex-1").set() browser.radio(id="exp-2").set() browser.text_field(id="datepicker").set("mmddyy") browser.checkbox(value="Automation Tester").set() browser.checkbox(id="profession-0").set() browser.link(text="Test File to Download").click() browser.checkbox(id="tool-0").set() browser.checkbox(id="tool-0").clear() browser.checkbox(id="tool-2").set() browser.close()