示例#1
0
def CreateNode(driver):
    '''
    Creates a New State Node assigning the NodeData Properties
    '''
    newNode = NodeData()
    newNode.link = driver.current_url
    newNode.domString = driver.page_source
    newNode.visited = 0
    newNode.title = driver.title
    logger.info("Creating a new node with title %s" % (newNode.title))
    return newNode
示例#2
0
def initState(domString, link, title, driver, globalVariables,depth,start_url,login_header):
    '''
    Initialize the State Machine adding a StateNode to fsm
    '''

    fsm = StateMachine()
    fsm.addHeaders(start_url, login_header)
    node = NodeData()
    node.link = link
    node.domString = domString
    node.title = title
    node.visited = 0

    node.clickables = GetClickables(domString)
    for item in node.clickables:
        print item.xpath
    node.backtrackPath.append(link) 
    fsm.addNode(0, node)
    driver.save_screenshot("snaps/" + str(0) + ".png")
    if frameExists(node.domString):
        logger.info("Crawling Frames")
        crawlFrame(0, fsm, driver, globalVariables)
    else:
        Crawl(0, fsm, driver, globalVariables, depth+1)
    #clickables = graph.node[curNode]['nodedata'].clickables
    logger.info("THE END")
    fsm.pathSourcetoSink()
    #print fsm.graph.edge
    drawGraph(fsm)