How Do I Force a SUBMIT on a JavaScript Web page using VS2010 C# WebBrowser Control

Greetings...

A little history: I deal in a Large number of Used CD's. On occasion I will off load some of my surplus to an on-line company that buys used CD's. This Company's website is located at http://www.decluttr.com/start-selling/. Previously the company was using .ASP they have now changed the website and is now mostly JavaScript. I wrote a small C# program that would interact with their PREVIOUS website using VS2010 and the WebBrowser Control. My program would load a list of UPC codes and then pass the list, one-at-a-time, to the UPC input box and execute the 'Submit' function.

My program worked well when the Website was written using ASP. It is now using Mostly JavaScript. I am an Old (65) and not very good Application programer, so I am having trouble trying to figure out how to Re-Write my program so that it Interacts properly with  JavaScript...

OK Nuff history... Here is what I have done and what I need to do:

I have been able to Gain/Force focus to the UPC input box. This Box BTW is contained within the only 'Form' on the page. Once I have 'Set Focus' on the input box I can then input a UPC code into the input box from the List. It Is at this point that I need to 'SUBMIT' the form  and wait for a response from the 'Decluttr' Application before Inputting the next UPC Code...

This is where the problem occurs... because this is JavaScript  I am not able to figure out how to Force the 'SUBMIT'..

I will provide both my Code and code from the Web page once someone picks this 'Request' up and is willing to work with me. I have 'Googled' to get as far as I have but now I am requesting additional help...

Thanks in advance
rrbecker
LVL 2
rrbeckerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sammySeltzerCommented:
I think I am missing the point here.

If you are trying to submit using javascript, then something like this:

<script type="text/javascript">
function submitform()
{
    document.forms["form1"].submit();
}
</script>

Open in new window


And form1 will look like this:

<form id="form1" action="process.asp">
Search: <input type='text' name='mysubmit'>
<a href="javascript: submitform()">Go</a>
</form>

Open in new window

0
Bob LearnedCommented:
If you are talking about the "Enter Barcode" input element, and the "Add to Basket" link next to it.

That HTML appears to be here:

<div id="ContentPlaceHolderDefault_mainContent_valueEngine_8_pnlValuation" class="left" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ContentPlaceHolderDefault_mainContent_valueEngine_8_getValSmall')">
      
       
            <input name="ctl00$ctl00$ctl00$ContentPlaceHolderDefault$mainContent$valueEngine_8$txtBarcode" maxlength="13" id="ContentPlaceHolderDefault_mainContent_valueEngine_8_txtBarcode" type="tel" class="" autocomplete="off">
            <input type="hidden" name="ctl00$ctl00$ctl00$ContentPlaceHolderDefault$mainContent$valueEngine_8$wtmBarcode_ClientState" id="ContentPlaceHolderDefault_mainContent_valueEngine_8_wtmBarcode_ClientState">

            <a id="ContentPlaceHolderDefault_mainContent_valueEngine_8_getValSmall" class="addtobasket" href="javascript:__doPostBack('ctl00$ctl00$ctl00$ContentPlaceHolderDefault$mainContent$valueEngine_8$getValSmall','')"><span class="show_Small">Get Price</span></a>
           
       
       
</div>

If you are using the WebBrowser control to automate this page, you don't need to do the JavaScript postback, you need to:

1) Get a reference to the <input> element

2) Enter text

3) Get a reference to the <a> element

4) Call the "click" method
0
rrbeckerAuthor Commented:
Hi Bob.. Great... then I am on the Right track.

Here is what I have done so far which allows me to direct Focus to the Barcore Input box and to populate that input box with a new Barcode from a list that I populate.

----------------------------------------------
foreach (string ThisUPCode in cmbUPCList.Items)
{
       cmbUPCList.Text = ThisUPCode;
       ElementFound = false;
       // 2:
       //var txt = document.getElementById("<%=txtName.ClientID%>");

       foreach (HtmlElement element in webBrowser1.Document.GetElementsByTagName("input"))
       {
            //ElementFound = false;
            if (element.Name == "ctl00$ctl00$ctl00$ContentPlaceHolderDefault$mainContent$valueEngine_8$txtBarcode")
              {
                      element.SetAttribute("value", ThisUPCode);
                      //element.Focus();
                      ElementFound = true;
                      break;
                }
          }

          if (ElementFound == true)
          {
                // 3:
               //HtmlElement form = webBrowser1.Document.GetElementById("sellit");
              //HtmlElement form = webBrowser1.Document.GetElementById("/start-selling");
              HtmlElement form = webBrowser1.Document.GetElementById("ctl01");
              if (form != null)
              {
                           
                    //onsubmit="javascript:return WebForm_OnSubmit();
                    //form.Document.InvokeScript("javascript:return WebForm_OnSubmit()");
                     form.InvokeMember("Submit");
                      PageComplete = false;
                       //MessageBox.Show("HERE");
              }
-------------------------------------

Here you will see that I have tried several things to get the form to Post properly. However If iunderstand you right then I actually need to get a reference to:

id="ContentPlaceHolderDefault_mainContent_valueEngine_8 instead of: ctl00$ctl00$ctl00$ContentPlaceHolderDefault$mainContent$valueEngine_8$txtBarcode


Ok let me Tinker with that info for awhile and I'll get back to you...

Thanks Bob, I really appretiate the help..

rrbecker
(Rick)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Bob LearnedCommented:
1) There is an ID for the <input> element, so you should be able to use Document.GetElementById("ContentPlaceHolderDefault_mainContent_valueEngine_8_txtBarcode")

2) For the anchor tag, <a>, you could use:
var anchor = Document.GetElementId("ContentPlaceHolderDefault_mainContent_valueEngine_8_getValSmall");

if (anchor == null)
    throw new NullReferenceException("txtBarcode");

anchor.InvokeMember("click");

Open in new window

0
rrbeckerAuthor Commented:
Hi Bob.. ok thanks..

I am working on it now so I will get back with you a bit later.. Today is Sunday so I have  few other thinbgs that take my time but I'll get back as soon as I can..

rrbecker

Rick
0
rrbeckerAuthor Commented:
Hi Bob.. Just a breif update.. I am still having a bit of a problem. I'm going to  "Freshen Up" what I have and then let you know how it goes..  

Thanks for the help and your paitents..

rrbecker
Rick
0
rrbeckerAuthor Commented:
Hi Bob.. Just a breif update.. I am still having a bit of a problem. I'm going to  "Freshen Up" what I have and then let you know how it goes..  

Thanks for the help and your paitents..

rrbecker
Rick
0
rrbeckerAuthor Commented:
Hi All.. I seem to have Double posted. How do I get rid of one?
0
Bob LearnedCommented:
Don't worry about the double post, there really isn't anything that you can do about it now.
0
rrbeckerAuthor Commented:
Ok Thanks...

Well I am going to try 1 more approach to this and if it still doesn't work I'll post my code and solicit more help... however,  can I get a reference to the FORM itself and then call the SUBMIT function? I have tried tried that but it still does not add anything to my 'Basket'. It is as though it is being passed and empty field... Maybe I am calling/using the wrong 'Key Word'... I am just using "MyForm.InvokeMember("submit");

I can make it work by populating the Input box with a single Barcode from my list and then manually 'Click' the Add button.... But via the program it just seems to 'Refresh' the page and nothing is added to the Basket...

Oh Well.. let me try this other approach and I'll let you know how it goes..  Again I must state and admit I am not very good at this...

rrbecker
Rick
0
Bob LearnedCommented:
Rick,

Here is what I did:

1) Added a WebBrowser control to a page

2) Added a reference to the Microsoft.mshtml library for better control (more granularity)

3) Attached to the DocumentCompleted event handler to get a reference to the DOM document (HTMLDocument), the input element (HTMLInputElement), and the anchor (HTMLAnchorElement).

 private bool _itemAdded;

        private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (_itemAdded)
                return;

           var htmlDocument = (mshtml.HTMLDocument)browser.Document.DomDocument;

            var barCode = (mshtml.HTMLInputElement)htmlDocument.getElementById("ContentPlaceHolderDefault_mainContent_valueEngine_8_txtBarcode");

            if (barCode == null)
                throw new NullReferenceException("Unable to find bar code input element");

            barCode.value = "0025192134319";

            var addButton = (mshtml.HTMLAnchorElement)htmlDocument.getElementById("ContentPlaceHolderDefault_mainContent_valueEngine_8_getValSmall");

            if (addButton == null)
                throw new NullReferenceException("Unable to find add button anchor element");

            addButton.click();

            _itemAdded = true;
        }

Open in new window



I was able to get a reference to the input element and set the value, and then get a reference to the anchor element, and call the "click" method, and the item was added.  You will note that there isn't a "using mshtml" statement anywhere, as this can really bog down Intellisense, since there are a too many members in that library.   I prefer to interact with the web page DOM with mshtml, since it gives you a lot more ways to solve a problem, and with Intellisense to boot.
0
rrbeckerAuthor Commented:
Wow Bob... Thanks,

I was using similar function in about the same places.. but to no avail... Maybe the reference to MSHTML is what i needed...

let me throw this into my code and I'll get right back to you..

I can't thank you enough...

rrbecker

Rick
0
rrbeckerAuthor Commented:
Hi Bob... Well I told you I wasn't very good at this..

I can get your code to work if I use the example EXACTLY the you have it inside the 'DocumentCompleted' handler but once I add it to My  btnStartDecluter_Click() function, it fails to work... Obviously I am overlooking something or the "Document Page" is not the page that I think it is..

Please forgive my igorance...

This is the 2 function that I believe are of interest.. Other function within my code just loads the List and clears cookies...

rrbecker

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            PageComplete = true;
            toolStripURL.Text = webBrowser1.Url.ToString();

            if (_itemAdded)
                return;

             
            //SuppressScriptErrorsOnly(webBrowser1);
        }

        private void btnStartDecluter_Click(object sender, EventArgs e)
        {
            // This is the main loop. The process is a follows
            // 1: loop trhough the combo box and grab each available UPC
            // 2: place the UPC Code into the Declutter Form
            // 3: execute/submit the decluttr.com form
            // 4: wait for the Web page to complete loading
            // 5: update the STATUS field in the UPC database
            // 6: Update the Progress bar
            // 7: Stop process after a Max of 200 UPC have been collected

            // 1:

            Boolean ElementFound = false;
            int i = 0;

            i = 0;
            progressBar1.Value = 0;
            // do the foreach loop here
            try
            {

                foreach (string ThisUPCode in cmbUPCList.Items)
                {
                    cmbUPCList.Text = ThisUPCode;
                    _itemAdded = false;

                    ////////////////////////////////////////////////////

                    var htmlDocument = (MSHTML.HTMLDocument)webBrowser1.Document.DomDocument;

                    var barCode = (MSHTML.HTMLInputElement)htmlDocument.getElementById("ContentPlaceHolderDefault_mainContent_valueEngine_8_txtBarcode");

                    if (barCode == null)
                        throw new NullReferenceException("Unable to find bar code input element");

                    barCode.value = ThisUPCode;

                    var addButton = (MSHTML.HTMLAnchorElement)htmlDocument.getElementById("ContentPlaceHolderDefault_mainContent_valueEngine_8_getValSmall");

                    if (addButton == null)
                        throw new NullReferenceException("Unable to find add button anchor element");

                    addButton.click();

                    _itemAdded = true;


                    ////////////////////////////////////////////////////////////

                    progressBar1.Value = ++i;
                } //end foreach loop
            }
            catch (Exception ex)
            {
            }

            //cmbUPCList.Items.Clear();
            //cmbUPCList.Text = "";

            //veify that the DONE folder exists. If not, create it
            if (!Directory.Exists(FullDeclutrQueueDir + @"Done\"))
            {
                Directory.CreateDirectory(FullDeclutrQueueDir + @"Done\");
            }

            // move the declutter Queue files to the Done folder
            string from = FileToProcess;
            string to = FullDeclutrQueueDir + @"Done\" + Path.GetFileName(FileToProcess);

            try
            {
                File.Move(from, to); // Try to move
            }
            catch (System.IO.FileNotFoundException ex)
            {
                MessageBox.Show(ex.ToString());
            }

            // now decrement the number of items InQueue
            try
            {
                txtInQueue.Text = Convert.ToString(Convert.ToDecimal(txtInQueue.Text) - 1);
            }
            catch (Exception ex)
            {
            }

        }

Open in new window

0
Bob LearnedCommented:
1) Has the document loaded before the button click happens?  

2) I used the _itemAdded flag since my code repeated the same process in an endless loop without it.  I think in your code is causes problems.

3) There is a little magic that you can use to convert to a synchronous process:

   
private bool _isReady;

    private void StartNavigation(string url)
    {
        _isReady = false;
        var counter = 0;
        browser.Navigate(url);
        do
        {
            Thread.Sleep(10);
            Application.DoEvents();
            counter++;
        } while (!_isReady || counter > 50000);

       if (counter > 50000)
           throw new InvalidOperationException("Document load timeout");
    }

   private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        _isReady = true;
    }

Open in new window


4) You can use this synchronous call in the for loop for button click.
0
rrbeckerAuthor Commented:
Hi Bob.. I  Had used a 'Timer'  similar to that in the first iteration of the code,, ( The code that worked before Decluttr Changed their code  ) and it worked well..

I have also tried it in this new code  but alas it did not help either...

Bob.. I am going to try to 'Combine' a couple suggestion from you and put them into the 'DocumentCompleted' function ( because that is where I can get it to work )  and see how that goes.. I'll set up a Counter to test to see if my 'List' is empty and if it is not then I'll pull the next Barcode and increment the counter. Hopefully I can get it to function properly...

Again thanks for all the help...
Rick
0
rrbeckerAuthor Commented:
Hi Bob...

Well I don't mind saying that I an getting frustrated.  I am now at the point where I can not even get you sample code to work,,,

I am going to start a Completely new project and have just the bare minimum amount of code and go from there. If I can get your example to work 'Consistently' then I'll move on from there..

However there is one piece of code that I will re-add and that is a piece of code that Clears the cache. This allows me to use the Same BarCode over and over again,

As  a side not I used your sample code and at the point where I/you added the BarCode to the Input, I tried pulling the BarCode from a Text Box that I had added to the webbrowser control and I never could get it to add... even with the 'time Out' code..

Thanks for putting up with me,, I'll get back as soon as I get a New Project build...

Rick
0
Bob LearnedCommented:
This is a pretty tricky operation, so I can understand your frustration.
0
rrbeckerAuthor Commented:
Thanks Bob..

Yea... it appears that they have used some 'Cross Platform' tools to  build their application. I am assuming that they changed from their original code to this so that they could provide Their 'Functionality' on 'Smart Phones'.

BTW... To the best of your knowledge would there be any advantage to using the Form's Submit event  instead of the Button Click Event?? If so then maybe I could or should  (with your help)  go back to that original thought. At this point I am not sure which approach to take,,

Anyway.. Let me get  some code together... chat in a bit..

Rick
0
Bob LearnedCommented:
For a little outside-of-the-box thinking...

1) What version of Visual Studio are you using (i.e. Visual Studio 2013 Ultimate)?

2) I recorded a Coded UI Unit Test in Visual Studio 2013 Ultimate, and I noticed that there is a problem with the playback.  I can add one DVD, but the second one fails:

Test Name:      CodedUITestMethod1

Result Message:      
Test method CodedUITestProject1.CodedUITest1.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException: Cannot perform 'SetProperty of Text with value "0794043749728"' on the control. Additional Details:
TechnologyName:  'Web'
ControlType:  'Edit'
TagName:  'INPUT'
Id:  'ContentPlaceHolderDefault_mainContent_valueEngine_8_txtBarcode'
Name:  'ctl00$ctl00$ctl00$ContentPlaceHolderDefault$mainContent$valueEngine_8$txtBarcode'
 ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
0
rrbeckerAuthor Commented:
Hi Bob...

Well I had originally written that in VS2010 but I do have access to VS2013 C# Express. Since I am going to start a new project I guess I can use VS2013 for any new development if it will help.

I am assuming from the Runtime error that there is something on their end that is causing a the COM Component error. If you are feeling like I am 'Beating A Dead Horse' let me know so that I won't continue to 'Pull My Hair Out'... hehe

Thanks
Rick
0
Bob LearnedCommented:
Rick, I try to get across to people that I am patient and persistent, and I don't give up easily.  This has become a personal challenge for me.  The COM exception is from the Coded UI automation, since it is a COM component, and not a problem on the Declutter web site.

I am trying out Selenium with a Google Chrome driver now.
0
Bob LearnedCommented:
Here is the code that I used.  I will explain it later, when I have a chance, but for now I am off to bed.

SeleniumFacade.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using Selenium;

namespace WindowsFormsApplication1
{
    public class SeleniumFacade
    {
        private ChromeDriver _chromeDriver;

        public SeleniumFacade()
        {
            var options = new ChromeOptions();
            options.AddArgument("test-type");

            _chromeDriver = new ChromeDriver(@"C:\Users\BobTLO\Downloads\chromedriver_win32", options);

        }

        public void Navigate(string url)
        {
            _chromeDriver.Navigate().GoToUrl(url);
        }

        public IWebElement FindElement(By by)
        {
                var wait = new WebDriverWait(_chromeDriver, TimeSpan.FromSeconds(5));
                 wait.Until(ExpectedConditions.ElementExists(by));
                     return _chromeDriver.FindElement(by);
        }

        public void SetElementText(IWebElement element, string text)
        {
            var script = string.Format(
                "document.getElementById('{0}').value = '{1}' ", element.GetAttribute("id"), text);

            var result = _chromeDriver.ExecuteScript(script); 
        }

        public void WaitPageLoad(int timeOutSeconds)
        {
            var wait = new WebDriverWait(_chromeDriver, TimeSpan.FromSeconds(timeOutSeconds));
            wait.Until(driver1 => _chromeDriver.ExecuteScript("return document.readyState").Equals("complete"));
        }

        public void Quit()
        {
            _chromeDriver.Quit();
        }

    }
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
Form1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using OpenQA.Selenium;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private SeleniumFacade _selenium;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            _selenium = new SeleniumFacade();

            _selenium.Navigate("http://www.decluttr.com/start-selling/");

            var list = new List<string> { "0025192134319", "0794043749728" };

            foreach (var item in list)
            {
                _selenium.WaitPageLoad(15);

                var barCodeInput = _selenium.FindElement(By.Id("ContentPlaceHolderDefault_mainContent_valueEngine_8_txtBarcode"));
                barCodeInput.Click();

                _selenium.SetElementText(barCodeInput, item);

                var addButton = _selenium.FindElement(By.Id("ContentPlaceHolderDefault_mainContent_valueEngine_8_getValSmall"));
                addButton.Click();
            }

        }

        private void Form1_Shown(object sender, EventArgs e)
        {

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            _selenium.Quit();
        }

    }
}

Open in new window

0
Bob LearnedCommented:
Selenium is used to automate web browser, and has specific drivers that you need to download, and configure.  I used the Chrome driver.  I was able to successfully load two bar codes in a for loop.

Good night!!
0
Bob LearnedCommented:
If you want to play with Selenium, then you can download from here:

Selenium C# download
http://www.seleniumhq.org/download/



And, the Chrome driver executable is here:

http://chromedriver.storage.googleapis.com/index.html?path=2.9/

      chromedriver_win32.zip



The driver takes a path to the ChromeDriver.exe:

      _chromeDriver = new ChromeDriver(@"C:\Users\BobTLO\Downloads\chromedriver_win32", options);
0
rrbeckerAuthor Commented:
Hi Bob...

Sorry but my PC is causing me fits.. I haved moved every thing to my Lap Top. Problem is that my Laptop has Ubuntu running on it so I now have my windows stuff now on a Virtual PC. This working Ok for me but I have to get everything Install and configured and stuff..

Anyway.. Yes let me look at that Selenium Code. I'll download it onto the Virtual Machine.

BTW I'll still be using VS2010 I hope that is ok..

Chat in a while

Rick
0
Bob LearnedCommented:
BTW I'll still be using VS2010 I hope that is ok..
You should be just fine running this, and if we run into a problem, then we can just deal with it.
0
rrbeckerAuthor Commented:
"...You should be just fine running this, and if we run into a problem, then we can just deal with it..."

Thanks Bob... BTW.. I gave up on the Virtual Machine.. Too slow... I'm going to move 'Stuff' to the Windows 7 partition. It is pretty full so I have to remove a bunch of stuff but I think it will be better in the long run. It already has VS2010 on it so I just have to Move the Project  and then load up Selenium...


Thanks again Bob

Rick
0
rrbeckerAuthor Commented:
Hey Bob...

Just FYI.. I am having trouble getting Selenium set up on VS2010 C# Express (Key word:  Express) ... I have found some information that describes a 'Work Around' so I am trying that now... I'll keep you up to date as to my progress.
0
Bob LearnedCommented:
If you need a nudge in the right direction, just remember to ask.
0
rrbeckerAuthor Commented:
Hi Bob...

Thanks for the offer ... we have been out doing the Memorial Day Thing so I haven't done much..

However... I have found out that VS2010 C# express is not 'Directly' supported by Selenium and or NuGet Package Manager. However I have found that there is a work around by which you Load up Visual Web Developer 2010 Express and through a bit of 'Horse Play' you can get VS2010 C# Express to accept the Nuget Package manager and Selenium.

I am most of the way through the process and I hope to have a 'Working'  Selenium system. There are a couple of things that the Work around is 'requiring' that I am not sure of at the moment. If I run into a snag and can't figure out what them mean then I'll as for help...

BTW here is the link that I am working from:
 http://faidootdoot.blogspot.com/2011/09/selenium-setting-up-with-microsoft.html

Thanks again Bob
0
rrbeckerAuthor Commented:
Hi Bob..

Ok, I finally got the References to Selenium into a VS2010 C# WindowsForm project. Now I'll see about getting a Reference to Chrome and IE ( I think I would like to stay with IE if at all possible ) .

I know that FireFox is the default so I might just try your sample with that Browser....

As Always I'll keep you informed as to my progress.

Rick
0
rrbeckerAuthor Commented:
Hi Bob.. Ok I have a new project created and it  Runs/Compiles without errors However it is coming up and displaying a Blank 'Form' And a Blank Chrome Web Browser,

I tried to use the Internet Explorer Driver and in that case only a Blank 'Form1' came up.

In Both cases it does Not Error Out,  just No Pages are displayed... It looks like it/they are having a problem when trying to 'Navigate' to the given URL. It Never leaves that Function call..

I am going to work on it some more and then I'll report back..

Rick
0
Bob LearnedCommented:
Rick,

There is a place where you should be able to upload the source code as a .zip file:

http://ee-stuff.com/

Just log in with your Experts-Exchange ID, and attach the .zip file to the question URL, and then post the file URL here.
0
rrbeckerAuthor Commented:
Hi Bob... Ok thanks

BTW... I was able to get your sample code to work so that is Great news... I still have to see if I can Re-Implement all the features of the original program.

I am still pretty unclear how this is all working but I am pretty good at taking a little help and stretching it a long way.

Which brings me to my next question. Your Sample Code pretty much fulfilled  the Original Request/Question. I would be happy to Accept your answer now.. However I am sure that as I re-Build the original application,that  I will have more questions pertaining to Selenium. Soooo will you be available for future question??

Thanks for your help

Rick
0
Bob LearnedCommented:
Rick,

There are a lot of experts available to answer questions, and with a variety of experience you may get more information than from just me.  If you ask a question, though, and you don't get an answer, you could post a message to me, and give me the question URL.  I only answer abandoned questions these days, since I get an E-Mail from the system with each question, and then I can decide which ones to answer.  Otherwise, I don't have the time, nor the inclination to search through all the open questions looking for one that I can answer.
0
rrbeckerAuthor Commented:
Hi Bob...

OK will do... however if you don't mind I would like to leave this open for another day or so.. I am going to create a ListBox on the 'Form' and populate it with a couple of BarCode.. I will then 'Start' the process and see if it can load out of the listbox . If all is well then I'll close the ticket..

Is this OK with you??

Rick
0
Bob LearnedCommented:
Rick,

Whatever you would like to do is OK with me.
0
rrbeckerAuthor Commented:
OK My Friend, I have a workable/working solution. I Thank you very much...

However 1 quick question... How do I suppress/hide the CMD window when it comes up. Is there a way to tell it 'Start Minimized' ??

I want to  'Clean Up' the screen a bit when the application runs.

Thanks for ALL your help..

Rick
0
rrbeckerAuthor Commented:
Thanks For being so patient and gracious  I appreciate it very much.

BTW I do not participate in Facebook Twitter or Linkedin... Sorry..
0
Bob LearnedCommented:
I found that answer for myself, so let me share it with you:

1) Create a ChromeDriverService, and hide the command window.

2) Pass the service to the ChromeDriver constructor.

Here is the change to SeleniumFacade:

 public SeleniumFacade()
        {
            const string CHROME_DRIVER_PATH = @"C:\Users\BobTLO\Downloads\chromedriver_win32";

            var options = new ChromeOptions();
            options.AddArgument("test-type");
            options.AddArgument("silent");

            var driverService = ChromeDriverService.CreateDefaultService(CHROME_DRIVER_PATH);
            driverService.HideCommandPromptWindow = true;

            _chromeDriver = new ChromeDriver(driverService, options);

        }
0
rrbeckerAuthor Commented:
Hi Bob..  I Just wanted to let you to know that I have everything working now, thanks to you.  I did however have to use the FireFox Driver because of some issues related to the Operating System.

Again, Thanks for you help...

Rick
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.