How to open a website with google chrome - vb.net

I am making a desktop search app. I need a way to set the web browser target to Google Chrome. I.e., if a person clicks a button in my app it will open Chrome with the website instead of Internet Explorer.

run the chrome exe with a url as the first arg
chrome.exe xkcd.com
So something like...
Process.Start("pathToChrome\\chrome.exe", "xkcd.com")

Related

Python Selenium Safari

I don't understand how this works:
If I open a website by hand in for example Safari or Chrome, I can log me on and if I close the browser I automatically log in after reopen the browser. So I once log in in Instagram, the next time I don't have to do it again if I reopen the side.
But if I open it with selenium, it won't work like this. Is there a way to give options in selenium to fix this? I can't open a side without the side thinks iam a robot (what actually is right) but this sucks...
When you quit the webdriver, the cookies, cache, history, etc are deleted. So if you want to be already logged in when you start the webdriver, you have to use the cookies from a profile on the normal browser in which you are already logged in. To do so you have to:
create a new chrome profile on the normal browser
login to instagram
load the profile in selenium
In this way when you start the webdriver and run driver.get('https://www.instagram.com/') you will be already logged in.
To create a new profile, open your chrome browser, click on the profile icon on top right, then click "Add" and then click "Continue without an account".
Then write a name for your profile and be sure check the box "Create a desktop shortcut". I suggest you to choose a color so that you will immediately see if it works when selenium open the browser window.
Open chrome from the new desktop icon (mine is called "PythonSelenium - Chrome.exe") and login to instagram.
After you logged in, close the browser and open the properties of the new desktop shortcut. Take note of the name of the profile directory, which in my case is "Profile 3".
Now we have to tell selenium to open the chrome driver using this new profile we've just created, which is logged in twitch. To do this we need the path of the folder where the profile is stored. By default the path is something like C:\Users\your_username\AppData\Local\Google\Chrome\User Data, if you are not sure about it check where chrome is installed in your computer.
Then run this code (remember to substitute Profile 3 with the name of your profile from step 3)
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\your_username\\AppData\\Local\\Google\\Chrome\\User Data")
options.add_argument("profile-directory=Profile 3") # <-- substitute Profile 3 with your profile name
chromedriver_path = '...'
driver = webdriver.Chrome(options=options, service=Service(chromedriver_path))
driver.get('http://twitch.tv/login') # it should redirect you to the homepage
And this is the result:

How to change the focus from chrome browser to internet explorer using selenium webdriver?

Scenario :
There is a button/link on a page opened in chrome browser and after clicking on a button/link it will navigate to the other link and opens in systems default browser i.e. Internet Explorer.
How to change the focus from chrome browser to internet explorer in selenium?
This is not possible.
You are starting your Chrome browser using the Chromedriver. You cannot handle Internet Explorer with your Chromedriver. You would need to use the IEDriver.
But as you did not start Internet Explorer using Selenium you would need to re-use an existing session. This is officially not supported see.
Nevertheless Tarun Lalwani was able to achieve this. See here and here.
I would suggest to save the link of the button/link before clicking on it and then start a new session using Internet Explorer and navigate to the saved link.

Google Drive Contents are not getting displayed when open with selenium on Chrome Browser

[Gdrive Issue with Selenium Chrome Browser]1
Configuration Details:
Chrome Version Version 72.0.3626.96
Chrome Driver Version 2.43
Selennium WebDriver 3.11.0
Issue Description:
We are able to successfully launch Gdrive with Chrome browser using selenium webdriver till 7 Feb 2019. But now other all apps like Gmail , Google hangout activities working fine on same browser but when opening google drive after page loading we are not getting content of page , We are not able to create folder, Not able to upload file. Only search file working.
Gdrive has some new script introduces as
No i don't think that it has to work, it has some Prerequisites for Integration to automate google drive you can also automate google drive api if you want i have shared the link with you it will help you to how to automate google driver or API
https://www.cigniti.com/blog/integrating-selenium-with-google-drive/

How to get Selenium Webdriver to run on Firefox browser as a different user?

I want to open an application website on Firefox browser using Selenium Webdriver as a different user.
Currently, I am using gecko driver to open that application link, it successfully opens up the browser but unable to open the application link.
But I am able to achieve the same manually by going to Mozilla Firefox icon and clicking on
"Run as different user"
option (as shown in below image) which further open a popup for user credentials and by entering Username and Password of different user there I am able to open the application link in browser.
So, is there any way that I can achieve same process using Selenium Webdriver and opens up my application link.
Thanks in Advance!!
You should rather create Firefox profile by running firefox.exe -p to launch profile manager. Then you can instantiate firefox web driver implementation and configure it to use given profile.
Are you sure that you want to use pre-configured profile? I find much easier to manage to run drivers in private/incognito mode and set cookies manually to configure tests.
You might provide firefox_binary as a parameter for the webdriver:
http://selenium-python.readthedocs.io/api.html
firefox_binary – Instance of FirefoxBinary or full path to the Firefox
binary. If undefined, the system default Firefox installation will be used.
...so, you might use a wrapper script to run firefox as the different user (use sudo in Linux).

Open url in specific browser locally

I have created a website, with a link button that opens a link in IE, and when I run the program locally,
Process.Start("iexplore.exe", myUrl)
works just fine.
However - when I have published my website and run the program from the webserver, every click on my link button will open IE - on the webserver...
Is there a way to make a specific browser open on the local machine?