SimpleBrowserDotNet/SimpleBrowser

findBy not working, i cant find anything, but currentHtml contain that id and element

bgachip opened this issue · 6 comments

This code not working

`

       var browser = new Browser();

        try
        {      

            browser.Navigate("{URL}");

            var button = browser.Find("a", FindBy.Id, "MainContent_ModuleContent_WSModule1_WSItemList_146_Tepper1_rptQty_lbtnSearchLinesProdgrp_1");

            if (button.Exists)
            {
                Console.WriteLine("EXISTS");
                button.Click();
            }
            else {
                Console.WriteLine("Not exists");
            }

        }
        catch (Exception ex)
        {
            browser.Log(ex.Message, LogMessageType.Error);
            browser.Log(ex.StackTrace, LogMessageType.StackTrace);
        }`

What does the source HTML look like? Are you sure the id exists in the HTML?

Remember that SimpleBrowser doesn't execute JavaScript. If the element you are trying to find is created dynamically by JavaScript, it doesn't exist as far as SimpleBrowser is concerned.

browser.currentHtml contains

<a id="MainContent_ModuleContent_WSModule1_WSItemList_146_Tepper1_rptQty_lbtnSearchLinesProdgrp_1" title="Divers" href="javascript:__doPostBack(&#39;ctl00$ctl00$ctl00$MainContent$ModuleContent$WSModule1$WSItemList_146_Tepper1$rptQty$ctl02$lbtnSearchLinesProdgrp&#39;,&#39;&#39;)">Divers&nbsp;(22)</a>

and I 'd like to find with this..

browser.Find("a", FindBy.Id, "MainContent_ModuleContent_WSModule1_WSItemList_146_Tepper1_rptQty_lbtnSearchLinesProdgrp_1");

In that case, you should be able to do this:

browser.Find("MainContent_ModuleContent_WSModule1_WSItemList_146_Tepper1_rptQty_lbtnSearchLinesProdgrp_1");

Can you share the URL of the page you are attempting to access with SimpleBrowser?

// NOT EXISTS : (

var button = browser.Find("MainContent_ModuleContent_WSModule1_WSItemList_146_Tepper1_rptQty_lbtnSearchLinesProdgrp_1");

            if (button.Exists)
            {
                Console.WriteLine("EXISTS");
            }
            else
            {
                Console.WriteLine("NOT EXISTS");
            }

I can, but it is a private url... can we chat somewhere, because this page is available after successfull login(it is working).

@bgachip Did you get this working? Can this issue be resolved?