Chomedriver selenium doesn't work under vpn - selenium

I encountered an issue rather strange. When I run python scripts with selenium under fortinet vpn they get stuck. It never gets past "data:," at the address bar. How fortinet detects chromedriver?
Example code:
from selenium import webdriver
browser = webdriver.Chrome('/usr/local/bin/chromedriver')
browser.get('https://www.google.com/')
No VPN:
https://i.stack.imgur.com/IFBF1.png
with VPN:
https://i.stack.imgur.com/WcE0W.png
update 1
Tried modifying _cdc as suggested in this question but had no progress:
Can a website detect when you are using selenium with chromedriver?
update 2
Just tried using Firefox and Safari. Both work fine under the VPN. It definitely blocks chromedriver on some way.

Related

Chrome browser opens but nothing happens after that in selenium

I am not able to figure out why selenium API's are not executing in chrome browser, while chromedriver and chrome version is identical.
Chromedriver Version -> 91.0.4472.19
Chrome Version-> 91.0.4472.124
Output: Chrome launches and "data;" comes written in URL Bar. Nothing happens after that and test continues in running state.
I have tested with chromedriver 89,90,91,92. But nothing seems to be working.
Have anyone faced this issue ever where chrome and chromdriver version were same but browser is not executing selenoum API?
Code:
Browser name is passed from testngXML file.
ChromeOptions options = new ChromeOptions ();
options.setBinary("C\\ProgramFiles(86)\\..\\chrome.exe"); (in this location, I have chrome 91)
.......
......
System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver.exe"); (Here I have chromedriver 91)
This issue was related to somehow chrome policies. In my corporate system, there was a policy adding in chrome browser from admin (In every 1 hour) which was marking "disableChromeDevToolBar" as true. This was making the inspect (ctrl+shift+I) also greyed out.
I tried to fix this part, by changing the "disableChromeDveToolBar" value from 1 to 0 ([Windor+r-> regedit-> HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]).
This made the inspect and selenium API execution working in the chrome browser.
Note: I did not do any change in chrome browser and chromedriver. Issue was purely because of this policy.
Trying to get that policy detail from support team, if I can find out, I will update here.

Headless Google Chrome Proxy Server Settings

I'm using Selenium webdriver with Google Chrome. This is the code I was using to set the proxy for chrome:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % my_proxy)
This code worked for months. I'm coming back now and it is not working... I've tried older versions of Selenium, Chrome, Chromium, and the webdriver. None of the changes I do seem to work :(
Additionally, running chrome.exe from the command line while passing --proxy-server does not work! Chrome silently ignores the passed proxy...
Does anyone have any idea what is going on here? I've spent days trying to figure out how to get this simple selenium script working... Thanks so much :)
EDIT: I just tried running chrome.exe with the --proxy-server flags on a friend who has the same computer as mine and it worked...
This was one of the chrome extensions I had installed... If chrome.exe --proxy-server=xxx is not working try removing all extensions.
Hopefully no one else has to waste 3 days on this :(

FireFox still not working for Protractor/Selenium tests?

I have a project suite of automation tests that uses Protractor and Jasmine. As of a couple months ago, my tests stopped working in FireFox. Everything works perfectly in Chrome, and almost perfectly in IE.. because why would IE work ya know.
There have been multiple posts about this and I've read through all of them, but I haven't been able to determine if there's a workaround/solution to this. It's not entirely a HUGE deal if my tests run in FireFox, but with a web application it's mighty nice to be able to test all instances.
Basically what happens when I run a test in FireFox:
Command prompt acts like everything is about to run properly (FireFox driver starts up.. server remains running etc etc)
Firefox opens for a split second (icon appears on the task bar, browser flashes on the screen and closes)
After a good minute or so protractor gives me the following message:
[firefox #01-0] WebDriverError: Unable to connect to host XXX on port XXX
after 45000 ms.
With a ton of DEBUG lines referring to JSON files and Firefox addons.
Any thoughts or other sources I could check out would be sweet. Many thanks in advance.
Problem is with latest Firefox support from latest selenium-server. Use geckoDriver and it will work.
Follow this URL

How to run the selenium code on linux using firefox without GUI?

I had redhat Linux server command line but there is no GUI for that and I need to run selenium code on this server with firefox. As I am new to selenium so I am not sure whether it will work or not.
For achieving this I had install Firefox on my Redhat linux machine successfully but not able to trigger that as it is showing no display found.
Is there any other way to achieve this for headless browsing, where virtually a firefox will be opened and selenium code can be executed without GUI. Is it possible to do??
You can use HtmlUnitDriver of selenium to use headless browsing but it will not open firefox and may be not loading all content to it's cache as same as firefox
Refer Below:-
https://code.google.com/p/selenium/wiki/HtmlUnitDriver
Another thing you can use is Phantomjs with selenium Webdriver. This is most using pattern by industries for headless browsing
Refer below:-
http://www.guru99.com/selenium-with-htmlunit-driver-phantomjs.html
Yes you can trigger selenium file using command line
http://www.tutorialspoint.com/testng/testng_executing_tests.htm
Bash file is running fine in windows for testng but it is not working in linux/mac
Now if still your firefox is not opening then it is basically issue of some setting with your OS with firefox
Refer that too :-
https://serverfault.com/questions/279036/open-terminal-via-ssh-run-firefox-display-not-found
May be you have problem with some permission in red hat
Hope it will help you :)

Selenium Testing Safari Extension

When you attempt to run Selenium tests in a scripting context whose origin is at "safari-extension://...", the session hangs. I believe the problem is caused by extension sandboxing, which means if I get Selenium running in the same origin as the extension I am testing, it should be possible to execute selenium commands in my extension.
Question: Can I incorporate the Safari Driver into my Safari extension during testing to circumvent sandboxing?
We modified the Safari driver to navigate extension:// pages, and the problem persists. It looks like Apple blocks Selenium at the extension level :(