Q:

Issue scraping with python and selenium getting the element to dispay text element

I have been trying to achieve a scrap using xpath when I last asked about this issue I will present my code and output and the desired output:
Code:
from re import findall,sub
from lxml import html
from time import sleep
from selenium import webdriver
from pprint import pprint
from xvfbwrapper import Xvfb

def parse(url):
    response = webdriver. Chrome()

    response.get(url)

    otherkeyElement = response.find_element_by_class_name('locu-menu-item-name')

    thekeyElement = response.find_element_by_css_selector('.locu-widget-wrapper #locu-render-output .locu-menu .locu-menu-item .locu-menu-item-name')

    gelkeyElement = response.find_element_by_xpath('//*[@id="locu-medium-container"]/div[1]/div/div[1]/div[2]/div[3]/div[1]/div[1]')

    if otherkeyElement:
        otherkeyElement
        pprint(otherkeyElement)

    if thekeyElement:
        thekeyElement
        pprint(thekeyElement)

    if gelkeyElement:
        gelkeyElement
        print(gelkeyElement)
        sleep(3)

    parser = html.fromstring(response.page_source,response.current_url)

    gelato = parser.xpath('//*[@id="locu-medium-container"]/div[1]/div/div[1]/div[2]/div[2]/div[1]/div[1]')

    for gelatos in gelato:
        print(gelatos)

if __name__ == '__main__':

    parse('http://www.lunarosagelato.com/menu')

This outputs similar element for class name css selector and xpath:
<selenium.webdriver.remote.webelement. WebElement 
    (session="01aab8caa61f2362ef2e5d988619d742", element="0.7957563181681526-1")>

The text I expect is Jamaican Lime Sorbetto.  Any help would really be appreciated. 

A:

When you print WebElement you get its to_string function, like any other object.  If you want the text linked to it use .text
otherkeyElement = response.find_element_by_class_name('locu-menu-item-name')
print(otherkeyElement.text)

