Skip to content

Instantly share code, notes, and snippets.

@EnTeQuAk

EnTeQuAk/foo.py

Created Nov 30, 2015
Embed
What would you like to do?
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
class RSTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.mouse = webdriver.ActionChains(self.driver)
self.driver.implicitly_wait(5)
self.base_url = "http://radioscreen.net/Cockpit-Beta/"
self.verificationErrors = []
self.accept_next_alert = True
def test_r_s(self):
driver = self.driver
driver.get(self.base_url)
driver.maximize_window()
driver.find_element_by_name("TE_Name").clear()
driver.find_element_by_name("TE_Name").send_keys("matthias")
driver.find_element_by_name("TE_password").clear()
driver.find_element_by_name("TE_password").send_keys("changeme")
driver.find_element_by_name("PB_login").click()
time.sleep(3)
driver.find_element_by_name("PB_Ads").click()
time.sleep(3)
input = driver.find_elements_by_xpath('(//*[@name="PB_AddAd"])')[1]
input.click()
time.sleep(3)
#driver.execute_script("arguments[0].scrollIntoView(true);", button)
#self.mouse.move_to_element(button).click(button).perform()
#driver.execute_script("document.getElementsByName('PB_AddAd')[0].click();")
#driver.find_element_by_name("PB_Push").click()
#time.sleep(5)
#driver.find_element_by_name("PB_logout").click()
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException, e: return False
return True
def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException, e: return False
return True
def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment