How to change the span value.

2,716 views
Skip to first unread message

Gaurang shah

unread,
Oct 10, 2012, 5:22:02 AM10/10/12
to seleniu...@googlegroups.com
I have a span in my HTML code as mention below 

<span class="t-input" style="background-color: transparent;">Gaurang</span>

would someone let me know how to set the value of that span, i mean how would I set something in place of "Gaurang" ???

Gaurang Shah

Gulshan Saini

unread,
Oct 10, 2012, 12:45:26 PM10/10/12
to seleniu...@googlegroups.com
Do you want to change HTML code?

Luke Inman-Semerau

unread,
Oct 10, 2012, 5:44:45 PM10/10/12
to seleniu...@googlegroups.com
in Java:

WebElement element = driver.findElement(By.cssSelector("span.t-input"));
((JavascriptExecutor)driver).executeScript("arguments[0].innerText = 'something'", element);

or python:

element = driver.find_element_by_css_selector("span.t-input")
driver.execute_script("arguments[0].innerText = 'something'", element)

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/a3bitbb16IoJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gaurang shah

unread,
Oct 11, 2012, 3:14:55 AM10/11/12
to seleniu...@googlegroups.com
Thanks luke. 

It worked. 

Gaurang Shah
Reply all
Reply to author
Forward
0 new messages