Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I programmatically click on a div in a web browser?
    primarykey
    data
    text
    <p>I have been trying for a few days now and still have had no success in programmatically clicking on this div. All of the other input fields and buttons are working fine using InvokeMember("click") and RaiseEvent("onclick"), but I am unable to click on the following div: </p> <pre><code>&lt;div class="pump request"&gt; onclick="$(this).push('kjhzsd94vibjktj584ed01', null, event)" &lt;/div&gt; </code></pre> <p>This div is repeated several times on a page, but I just want to click on the first occurrence.</p> <p>This is what I have done so far:</p> <pre><code> HtmlElementCollection c1 = wbc1.document.GetElementsByTagName("div"); foreach (HtmlElement e2 in c1) { if (e2.GetAttribute("class").Contains("pump request"))//also this condition is not returning true { e2.RaiseEvent("onclick"); } } </code></pre> <hr> <p>@bleepzter</p> <p>what if "somecontrol" is a class of the div instead of div's id?</p> <p>since in my case i have div class "pump request" so (if i write "pump request" as somecontrol in above example) it return me Null in someDiv</p> <pre><code>&lt;div class="pump request"&gt; onclick="$(this).push('kjhzsd94vibjktj584ed01', null, event)" &lt;/div&gt; </code></pre> <p>@Cameron</p> <p>yep i did entered the break; but the problem is the if condition never returns true so </p> <pre><code> HtmlElementCollection c1 = wbc1.document.GetElementsByTagName("div"); foreach (HtmlElement e2 in c1) { if (e2.GetAttribute("class").Contains("pump request"))//--&gt; This condition is not returning true { e2.RaiseEvent("onclick"); break; } } </code></pre> <p>@Ilya Kogan</p> <p>yea i just did a watch on e2.GetAttribute("class") and the weird thing happened that being reading the actual div (which i want to click) the value of class was empty :-o</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload