Created
October 18, 2016 16:37
-
-
Save max3903/a5ba4a8fdabec18ae943a21174b698d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import httplib | |
from selenium.webdriver.firefox.webdriver import WebDriver | |
success = True | |
wd = WebDriver() | |
wd.implicitly_wait(60) | |
def is_alert_present(wd): | |
try: | |
wd.switch_to_alert().text | |
return True | |
except: | |
return False | |
try: | |
wd.get("http://localhost:8069") | |
# wd.find_element_by_link_text("Test").click() | |
wd.find_element_by_id("login").click() | |
wd.find_element_by_id("login").clear() | |
wd.find_element_by_id("login").send_keys("admin") | |
wd.find_element_by_id("password").click() | |
wd.find_element_by_id("password").clear() | |
wd.find_element_by_id("password").send_keys("admin") | |
wd.find_element_by_css_selector("button.btn.btn-primary").click() | |
wd.find_element_by_link_text("Sales").click() | |
wd.find_element_by_link_text("Sales").click() | |
wd.find_element_by_link_text("Sales").click() | |
wd.find_element_by_link_text("Quotations").click() | |
wd.find_element_by_xpath("//div[@class='o_list_buttons']//button[normalize-space(.)='Create']").click() | |
wd.find_element_by_id("o_field_input_3").click() | |
wd.find_element_by_id("o_field_input_3").clear() | |
wd.find_element_by_id("o_field_input_3").send_keys("Customer") | |
wd.find_element_by_link_text("Create \"Customer\"").click() | |
wd.find_element_by_link_text("Add an item").click() | |
wd.find_element_by_xpath("//div[@id='notebook_page_20']/div[1]/div[2]/div[1]/div[1]/div/input").click() | |
wd.find_element_by_xpath("//div[@id='notebook_page_20']/div[1]/div[2]/div[1]/div[1]/div/input").clear() | |
wd.find_element_by_xpath("//div[@id='notebook_page_20']/div[1]/div[2]/div[1]/div[1]/div/input").send_keys("Product") | |
wd.find_element_by_link_text("Create \"Product\"").click() | |
wd.find_element_by_xpath("//div[@id='notebook_page_20']/div[1]/div[2]/div[1]/input[1]").click() | |
wd.find_element_by_xpath("//div[@id='notebook_page_20']/div[1]/div[2]/div[1]/input[1]").clear() | |
wd.find_element_by_xpath("//div[@id='notebook_page_20']/div[1]/div[2]/div[1]/input[1]").send_keys("100.000") | |
wd.find_element_by_xpath("//div[@id='notebook_page_20']/div[1]/div[2]/div[1]/div[4]/span/span[2]").click() | |
# Save quotation | |
wd.find_element_by_xpath("//div[@class='o_form_buttons_edit']/button[1]").click() | |
# Confirm quotation | |
wd.find_element_by_xpath("//div[@class='o_statusbar_buttons']/button[8]").click() | |
wd.find_element_by_xpath("//div[@class='o_statusbar_buttons']/button[8]").click() | |
wd.find_element_by_xpath("//div[@class='o_statusbar_buttons']/button[8]").click() | |
wd.find_element_by_xpath("//div[@class='o_statusbar_buttons']/button[8]").click() | |
# Create invoice | |
wd.find_element_by_xpath("//div[@class='o_statusbar_buttons']/button[1]").click() | |
# Create and View Invoice | |
wd.find_element_by_xpath("//div[@class='modal-footer']/div/footer/button[1]").click() | |
# Validate invoice | |
wd.find_element_by_xpath("//span[normalize-space()='Validate']").click() | |
# Register Payment | |
wd.find_element_by_xpath("//div[@class='o_statusbar_buttons']/button[5]").click() | |
# Select Bank payment method | |
if not wd.find_element_by_xpath("//select[@id='o_field_input_85']//option[2]").is_selected(): | |
wd.find_element_by_xpath("//select[@id='o_field_input_85']//option[2]").click() | |
# Register Payment | |
wd.find_element_by_xpath("//div[@class='modal-footer']/div/footer/button[1]").click() | |
# Go to home page | |
wd.get("http://localhost:8069") | |
wd.find_element_by_link_text("Accounting").click() | |
wd.find_element_by_link_text("Reporting").click() | |
wd.find_element_by_link_text("Trial Balance").click() | |
# Logout | |
wd.find_element_by_link_text("Administrator").click() | |
wd.find_element_by_link_text("Log out").click() | |
except httplib.BadStatusLine: | |
pass | |
finally: | |
wd.quit() | |
if not success: | |
raise Exception("Test failed.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment