Thursday, 15 May 2014

c# - Getting element by Id -



c# - Getting element by Id -

selenium, nunit testing, c#, visual studio.

how, in selenium webdriver, can locate element in page source looks following, , set text in <p> tag:

<body contenteditable="true" class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" spellcheck="false"> <p></p> </body>

this body tag ckeditor component nowadays on page (not main page <body> element ). actually, need set text in <p> element. confusing me , class attribute complicated, contains several strings. aware of command: driver.findelement( by.classname( "some_class_name" )); how utilize in case , set text in <p> element?

if give p tag id so

<p id="derp">text here</p>

you can send text using selenium this

driver.find_element_by_id("derp").sendkeys("herp");

hope helps!

edit: without adding id element, might able this

driver.findelement(by.classname("some_class_name")).findelement(by.tagname("p")).sendkeys("herp");

c# selenium selenium-webdriver

No comments:

Post a Comment