Restrict browser exiting Selenium - java

I have a little app that uses selenium and works with two Chrome browsers simultaneously.
I was wondering if there is a way to restrict permission to close the browsers.
I mean I want a user to be able to ONLY close the program by using the GUI window but not turning off the browser.

Related

Best way to ship selenium with java application?

I am writing a java application which has one use: to fill out and submit a form on a webpage (without showing GUI of a browser). I have chosen Selenium for this.
However, how do I "pack" or "ship" Seleniums required browsers with my application? I.e. Selenium requires a browser executable to run the webdriver. I do not know which browser my target audience is using. How do I ship my application to run on any windows clients computer, without requiring them to manually install the browser?
Or am I on the wrong trail and there is a better option than selenium to fulfill my needs?

How to get rid google chrome helper message pop up

In macOS, when you set the chromedriver to headless, google chrome helper will pop up an annoying
window
If you close the window, the program will break, if you choose always allow, it will also break, the only way is to let it sit and do nothing while the program is working behind it until it finishes and you're allowed to close this window.
This is so annoying, I want to publish my program and I don't want my mac users to get disturbed by this.
Use another headless browser instead
nope. No can't do, HTMLUnitDriver javascript engine is useless. PhantomJS and JBrowser? Obsolete, no Java 11 support.
The window only shows when the chromedriver is headless and on the macOS.

Error: When i minimize Internet Explorer which is running the automated WebDriver Code

I have written the Selenium webdriver java code to automate the test and its working fine. But I have lot of data input to test my web and it takes time. So when i minimize the IE to do some other task while it is running the automation, it is throwing error:
org.openqa.selenium.ElementNotVisibleException: Element is not displayed
Selenium WebDriver is trying to simulate "real" users interaction with the webpage. If a person can't click on a button not currently displayed, neither can Selenium.
ElementNotVisibleException occurs when the element you want to interact with is not displayed. When you minimize the browser some of the elements are no longer visible, even though they where in maximized window.
You can add scroll using moveToElement() from Actions class every time you want to perform any action (I don't recommend it, you increase significantly the chance for errors), or find another hardware solution, like plugging in another screen, run the test on another computer etc.
According to my experience, the Internet Explorer WebDriver is very oversensitive when it comes to disturbances from a real user while running test cases. It's better to not touch anything at all. ;-)
Try Chrome! This is much more robust and also faster.
Selenium script runs as a simulator. You cannot do another work when script is running. Chrome is fast but while running script in chrome you can not do other task like any other browser. If you minimize window, you will get exception "ElementNotVisible".

How to get browser window front while running the test using selenium webdriver?

I'm currently running my selenium webdriver tests in 2 browsers (studentdriver and tutordriver)
studentdriver = new ChromeDriver();# opening student in chrome browser
tutordriver = new FrefoxDriver();#opening tutor with firefox browser
and I'm student browser first and then tutorbrowser soth that student browser will be behind and tutorbrowser will be on front side. when script running with studentbrowser, it will automatically comes fron and tutorbrowser will be back side but when script start running using tutorbrowser it is not coming front side and it is creating some problem in between.
I need a solution to get tutorbrowser front when script start running on tutorbrowser.
Note: I should not close studentbrowser because I'm closing both the browsers in #After
((JavascriptExecutor) driver).executeScript("window.focus();");
try this with each driver.
Unfortunatly, this is an OS problem. It's up to the window manager to handle the ovelapping, tiling, organisation of the windows, which you can't control directly from your code.
The best bet you'll have is to launch a Sikuli Robot with which you'll be able to bring back the correct window. It's a bit of work, though, to include in your tests, but it can be used from Java with no problem
See the beast at http://www.sikuli.org

Execute Selenium Commands on a Browser that is already open

I am looking for an example code that will allow me to run Selenium commands against a browser that is already open.
Typically when you start testing with Selenium it opens a new instance of the browser. But I am looking
for a solution where you would run the script and it will just start executing its codes on whatever browser and tab is currently visible.
Is that possible?
As per my knowledge this is not possible with selenium.
You have to open browser during the test script only otherwise it won't be able to identify or capture already opened browser's object.
No its not. There is an old issue still open since 2009.

Categories

Resources