import re
from base_page import BasePage

from graph_page import GraphPage, script_returns_true
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from arches.urls import uuid_regex

class NodePage(BasePage):
    """
    class to initialize the login page

    """

    def __init__(self, driver, live_server_url, graph_id):
        self.driver = driver
        self.live_server_url = live_server_url
        self.graph_id = graph_id
        self.base_url = 'graph/' + self.graph_id

    def get_graph_id(self, graph_id):
        print graph_id
        return graph_id

    def add_new_node(self, data_type_name):
        self.driver.get(self.live_server_url + '/' + self.base_url)

        wait = WebDriverWait(self.driver, 20)

        wait.until(
            EC.invisibility_of_element_located((By.CSS_SELECTOR, ".loading-mask"))
        )

        self.driver.find_element_by_xpath("//*[@id='node-crud']/ul/li[2]/a").click()

        xpaths = [
            "//div[@id='branch-library']//div//div[@class='library-card']", #first branch in branch list
            "//*[@id='branch-append']", #branch append button
            "//*[@id='node-form']/div[1]/div/div[2]/div[2]/div/a" #selected node in left container
        ]

        for xpath in xpaths:
            wait.until(
                EC.element_to_be_clickable((By.XPATH, xpath))
            ).click()

        selected_data_type = ''
        for el in self.driver.find_elements_by_class_name('active-result'):
            if el.text == data_type_name:
                selected_data_type = el

        selected_data_type.click()

        save_edits = self.driver.find_element_by_xpath("//*[@id='content-container']/div/div[4]/div[3]/span/button[2]")
        save_edits.click()

@@ -963,361 +963,683 @@
     
-self.driver.find_element_by_xpath(%22//*%5B@id='node-crud'%5D/ul/li%5B2%5D/a%22).click()%0A%0A        xpaths = %5B%0A            %22//div%5B@id='branch-library'%5D//div//div%5B@class='library-card'%5D%22, #first branch in branch list%0A            %22//*%5B@id='branch-append'%5D%22, #branch append button%0A            %22//*%5B@id='node-form'%5D/div%5B1%5D/div/div%5B2%5D/div%5B2%5D/div/a%22 #selected node in left 
+xpaths = %7B%0A            'new_node_button': %22//*%5B@id='node-crud'%5D/ul/li%5B2%5D/a%22,%0A            'first_in_branch_list': %22//div%5B@id='branch-library'%5D//div//div%5B@class='library-card'%5D%22,%0A            'append_button': %22//*%5B@id='branch-append'%5D%22,%0A            'selected_node_in_left_container': %22//*%5B@id='node-form'%5D/div%5B1%5D/div/div%5B2%5D/div%5B2%5D/div/a%22,%0A            'save_edits_button': %22//*%5B@id='content-container'%5D/div/div%5B4%5D/div%5B3%5D/span/button%5B2%5D%22%0A        %7D%0A%0A        self.driver.find_element_by_xpath(xpaths%5B'new_node_button'%5D).click()%0A%0A        xpaths_to_wait_on = %5B%0A            xpaths%5B'first_in_branch_list'%5D,%0A            xpaths%5B'append_button'%5D,%0A            xpaths%5B'selected_node_in_left_
 cont
@@ -1643,16 +1643,18 @@
 ontainer
+'%5D
 %0A       
@@ -1684,16 +1684,27 @@
 n xpaths
+_to_wait_on
 :%0A      
@@ -2092,71 +2092,35 @@
 ath(
-%22//*%5B@id='content-container'%5D/div/div%5B4%5D/div%5B3%5D/span/
+xpaths%5B'save_edits_
 button
-%5B2%5D%22
+'%5D
 )%0A  

Put xpaths in a dictionary so that dictionary keys, rather than raw xpaths, are in code logic. This makes the code more readable. Merged in master to get bower changes so that build will pass on travis re #1074