Hi everybody,
I'm getting crazy trying to find out how to get a element value from a javascript dynamic generated page:
Following is the html code for the element that I'm trying to get:
<td>
<script type="text/javascript">
<input id="t08451" type="text" readonly="" onkeypress="if(checkEnterInText(event)) { writeParameter('t08451',this.value); restartUpdate(this); };" onblur="writeParameter('t08451',this.value); restartUpdate(this);" onfocus="stopPeriodicUpdate(this);" title="" size="10" maxlength="10" value="" name="t08451">
</td>
This is my pytnon code:
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
# Create new istance of Firefox driver
binary = FirefoxBinary('/Applications/Programmi/Internet/Firefox.app/Contents/MacOS/firefox')
driver = webdriver.Firefox(firefox_binary=binary)
print ('creata istanza webdriver')
# Goto URL
driver.get('
http://xxx.xxx.xxx.x/page1.htm')
# Print title
print 'Titolo pagina: '
print driver.title
# find the element that's name attribute is t08451 ovvero EVC AO04 Enjector Control
driver.implicitly_wait(10) # seconds
element = driver.find_element_by_name("t08451") # it works same way with by ID locator
print 'element: '
print element
driver.implicitly_wait(10) # seconds
element_value = element.get_attribute('value')
print 'Value: '
print element_value
driver.quit()
and this is the output of the script:
$ python2.7 ./sel_fire.py
creata istanza webdriver
Titolo pagina:
I/O
element:
<selenium.webdriver.remote.webelement.WebElement (session="c5644dcd-5566-c942-9d00-0ce99be37f11", element="{c8a361ee-02ef-5a4c-ba9f-cf9ee34c94b5}")>
Value:
$
As you can see I receive back a blank value. I've also tried to use the driver.execute_script method with no solution, but any help will be appreciate.
Thanks in advance.
Luca