Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

vb.net cef browser click on button with no id help me pls

Hi every one i try to click on this button "<button type="submit" class="button" name="login" value="Log in">Log in</button>" bu what so ever i couldn't find a solution i tried with this code

  Dim jsScript2 As String = <js><![CDATA[
        document.all("login").click();
                    ]]></js>.Value
            bs.ExecuteScriptAsync(jsScript2)
this is just working with id buttons is not work on this many thanks in advance
I think we need a little bit more information to help you, from what I can see, you want to click a button that then clicks the browsers loaded page that has a login button on it?

To do so you can get each element that has button and then click the one that has the value "Log in"

Check out this link to get an idea on how to get that to  work: https://stackoverflow.com/questions/1110...-by-vb-net
Looks like your using the CefSharp .net browser github.com[slash]cefsharp[slash]CefSharp so you just need to inject the correct javascript to select/click the button
thanks for every one to reply to me but my problem is i want to make a click on the button what it not have a id on the id buttons works fine with a code above but others are not and i looking for a solution for that if is possible thank you in advance
So you could use something like the following:


Code
// get all the elements with the class 'button'
var btns = document.querySelectorAll(".button");

// loop through all the elements found
for (var i = 0; i < btns.length; i++) {
    // click all of the buttons
    eventFire(btns[i], 'click');

    // console log test
    console.log('btn: ', btns[i]);
}

// simulate a click
function eventFire(el, etype){
  if (el.fireEvent) {
    el.fireEvent('on' + etype);
  } else {
    var evObj = document.createEvent('Events');
    evObj.initEvent(etype, true, false);
    el.dispatchEvent(evObj);
  }
}

If there are multiple elements with the class name 'button' and you'd only want to click that specific element (button), you can do a few extra checks in the loop to narrow it down base on the info that the button has got.

e.g.
Code
// loop through all the elements found
for (var i = 0; i < btns.length; i++) {

    // check the name and value attributes
    // Then only click the button if the name = login and value = Log in )
    if( btns[i].getAttribute('name') == 'login' && btns[i].getAttribute('value') == 'Log in'){
        // click all of the buttons
       eventFire(btns[i], 'click');
    }
   

    // console log test
    console.log('btn: ', btns[i]);
}
thanks for the answer but i looking for a solution in vb.net but the above code not working with my code so i just suggest it is a different code
(Sep 15, 2020 07:41 AM)triplextreme Wrote:  thanks for the answer but i looking for a solution in vb.net but the above code not working with my code so i just suggest it is a different code

the code provided above is in c#... just convert it to vb.net using following online converter & use it...

https://converter.telerik.com/
BTC - bc1q3efew3yzfwhdz290dafykaw0a2w56g2j69g2c6
ETH - 0xf1c873217032468990D3313da6509D1b813c4671
USDT - 0xf1c873217032468990D3313da6509D1b813c4671
PP - [email protected]
(Sep 15, 2020 07:41 AM)triplextreme Wrote:  thanks for the answer but i looking for a solution in vb.net but the above code not working with my code so i just suggest it is a different code

Code
// loop through all the elements found
for i as integer = 0 to btns.length

    // check the name and value attributes
    // Then only click the button if the name = login and value = Log in )
    if btns(i).getAttribute("name") = "login" and btns(i).getAttribute("value") = "Log in" then
        // click all of the buttons
       eventFire(btns(i), "click")
    End If
  

    // console log test
    console.log("Button - " + btns(i).tostring())
next

Roughly converted it to VB of the top of my head try that.
[Image: DreddSig.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by The Pulp FictionApr 24, 2022 12:22 AM 2 195 Apr 24, 2022 12:22 AM
Last Post: The Pulp Fiction
[C] by ShoppaMay 20, 2019 12:13 PM 1 187 May 20, 2019 12:13 PM
Last Post: int
[.NET] by Formula 1Feb 28, 2019 02:31 PM 2 187 Feb 28, 2019 02:31 PM
Last Post: Formula 1