简体   繁体   中英

Read variables from javascript in selenium

I am using Selenium Webdriver 2.0. Html page being tested, includes x.js file and the variable "price" is defined in x.js based on some data entered from the html form and some calculations on the javascript. HTML prints the right value of price using: <td>$ <span id="price"></span></td> How can I catch the value of a price from the javascript?

假设价格显示为<span></span>内的文本,请尝试以下操作:

driver.findElement(By.id("price")).getText();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM