Results 1 to 5 of 5

Thread: How do I establish an open connection to an open web browser in C#?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2011
    Posts
    18

    How do I establish an open connection to an open web browser in C#?

    How do I establish an open connection to an open web browser in C#?

    In a Microsoft C# program using a Visual Studio Code I am using the following namespaces:

    Code:
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Support.UI;
    After I get a string variable, "url", assigned with a URL of a website page, I use the following commands which successfully opens a browser window and loads the web site:

    Code:
    IWebDriver driver = new ChromeDriver();
    driver.Navigate().GoToUrl(url);
    But this opens a chrome browser which is denoted somewhere as being a "test" session. It somehow knows it was launched from a program. And, since I am using this program to automate some interactions with linkedin, this information is passed along to linkedin which prompts me that it requires I login. This creates a cascading seriies of events that are difficult to automate including using my cell as a means of verification.

    So, instead of taking this route, how do I establish an open connection to an open web browser in C#? I figure, if I instead connect to a web browser that is already open and already has its veriication steps done with linkedin, then I won't be prompted to log in and do any user verification.

    On a personal note, if this is intentional security measures to prevent people from abusing a system, then this is a sad thing.

    On a broader view, will all this mean I will have to make a web browser from scratch?

  2. #2
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,958

    Re: How do I establish an open connection to an open web browser in C#?

    Automation like this is against their terms https://www.linkedin.com/legal/user-agreement#dose however they do have an api https://learn.microsoft.com/en-us/linkedin/ that you can use

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2011
    Posts
    18

    How do I establish an open connection to an open web browser in C#?

    How do I establish an open connection to an open web browser in C#?

    In a Microsoft C# program using a Visual Studio Code I am using the following namespaces:

    Code:
     using OpenQA.Selenium;
     using OpenQA.Selenium.Chrome;
     using OpenQA.Selenium.Support.UI;
    After I get a string variable, "url", assigned with a URL of a website page, I use the following commands which successfully opens a browser window and loads the web site:

    Code:
     IWebDriver driver = new ChromeDriver();
     driver.Navigate().GoToUrl(url);
    But this opens a chrome browser which is denoted somewhere as being a "test" session. It somehow knows it was launched from a program. And, since I am using this program to automate some interactions with linkedin, this information is passed along to linkedin which prompts me that it requires I login. This creates a cascading seriies of events that are difficult to automate including using my cell as a means of verification.

    Here, let me show you what I am up against. This screen shot:
    Name:  01.png
Views: 805
Size:  147.8 KB
    https://www.likablelogic.org/images/Direct/01.png
    shows that the web browser that my code launches through selenium commands has a label on it, "Chrome is bring controlled by automated test software". Yes, and I wrote this automated test software.

    What is most annoying is the fact that there is no log in to the session which is done automatically when I normally launch a browser. Here see this screen shot
    Name:  02.png
Views: 836
Size:  146.2 KB
    https://www.likablelogic.org/images/Direct/02.png
    where you can see that the user icon is this nondescript non-person.
    I made a video to demonstrate how pointless and frusturating this is:



    So, instead of taking this route, how do I establish an open connection to an open web browser in C#? I figure, if I instead connect to a web browser that is already open and already has its veriication steps done with linkedin, then I won't be prompted to log in and do any user verification.

    On a personal note, if this is intentional security measures to prevent people from abusing a system, then this is a sad thing.

    On a broader view, will all this mean I will have to make a web browser from scratch?

    I do not think so. Here is the bottom line. I am using selenium commands. Selenium is used for software testing. So there must be some way to attack a C# program to an actively open chrome web browser and interact with it. How do I do that?

    Is it better to use a different browser other than Chrome? How would I do that in C# code?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How do I establish an open connection to an open web browser in C#?

    It's not OK to create multiple threads for the same issue. If you want to add more information, add a post to the existing thread. Threads merged.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,958

    Re: How do I establish an open connection to an open web browser in C#?

    Quote Originally Posted by Xarzu View Post
    On a broader view, will all this mean I will have to make a web browser from scratch?

    I do not think so. Here is the bottom line. I am using selenium commands. Selenium is used for software testing. So there must be some way to attack a C# program to an actively open chrome web browser and interact with it. How do I do that?

    Is it better to use a different browser other than Chrome? How would I do that in C# code?
    Or you could try using the API like I already suggested. Automating access to LinkedIn is against their T&Cs and they are probably making it harder to do this to prevent people doing exactly what you are trying to do. Creating an entire web browser from scratch is a massive undertaking, doing this to circumvent the current system seems overkill; especially as they could change the system at any point and completely render your custom browser useless in this regard.

    The API exists as a way to get at information in a supported way, it is going to be a lot easier to use a supported method than create a web browser from scratch.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width