How to access a dynamically created element



  • 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 
    if(div.exists) //the control does not go inside { //code to edit div contents. } }


  • 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.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2