Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am using Watin to test a website. It contains a div which is created dynamically on clicking a tablecell. How can I access the dynamically created div. The issue is the div is deleted after a short span of time (even before the control can move to next line)

 if(tablecell.exists)
{
tablecell.ClickNoWait(); //this creates the dynamic <div>
if(div.exists) //the control does not go inside 
{
//code to edit div contents.
}
}
share|improve this question
    
Could you update your post with the HTML/JavaScript referencing the div? The way you access it will depend on how the div is coded. –  Kate Paulk Mar 6 at 12:05
    
<div class="somevalue" style="somevalue"> <input type="text" value="" name="somevalue" id="processing"> </div> the <div> element is created after clicking a tablecell and is destroyed immediately if we click or do anything anywhere else. –  Adwait Mar 7 at 4:20
    
Can you please edit the question, as well as giving the HTML around the div and the javascript that "creates" the div element? There's a difference between the div contents being generated dynamically in response to an event through javascript and the contents being made visible in response to an event. –  Kate Paulk Mar 10 at 11:22
    
Thank you for reply, but the problem has been solved. –  Adwait Mar 12 at 4:36
    
In that case, could you answer your question with the solution you found and mark it as answered? That will help others who have the same problem. –  Kate Paulk Mar 12 at 11:06

1 Answer 1

up vote 0 down vote accepted

I used threading. I put the main thread to sleep. and then started the child thread which was responsible for handling the textbox

current_frame.Div(Find.ById(id)).Table(Find.ById(id)).TableCell(Find.ByClass(id)).TableCell(Find.ByClass(id)).ClickNoWait();
                  Thread.Sleep(0);
                  child_thread.SetApartmentState(ApartmentState.STA);
                  child_thread.Start();
                  child_thread.Join();

child_thread contains code for editing the textbox.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.