(batch file) open/close tab in already open browser - batch-file

Is there a possibility to just open and close one single tab in a already running chrome browser session? I dont want to start a whole new browser like the command
start chrome.exe http://stackoverflow.com/
does it. Does someone have an idea how i could realize this?

I now found a way for opening a new tab on a already running browser:
start "webpage name" "http://stackoverflow.com/"
But I still don't know what the command for closing a single tab in a browser is.

Open Tab:
start "www.Discord.com"
or
start "https://Discord.com"
I still dont have any type of command that closes a tab on browser...

Related

i'm having issues opening the console for my App, i'm using firefox

I'm currenty working on a register/signup page, i'm in the middle of connecting my server with the front, so i want to do some testing in the console to make sure everything is working fine, however, when opening the console it redirects me to the Debugger tab.
It is not letting me do anything.
How can i get rid of it?
i figured it out
i deactivated the breakpoints and then i clicked on the pause breakenter image description here

How to best handle file upload failures in selenium webdriver

I am looking for any ideas on how best to handle file upload failures in selenium webdriver.
Recently I have been seeing a higher number of failures in my webdriver test suite, the error I am trying to fix is a failure in the Internet Explorer tests caused by a file upload failing.
In webdriver the only way I know to upload a file to an input element is to use the SendKeys() method and pass the file path to SendKeys() this works like a charm in chrome and firefox but periodically have had issues with it in Internet Explorer. What appears to happen is the file upload window gets opened but the path is not typed nor is the file uploaded. This leaves the node with a file upload window open, being this is a native window's window and not a webpage selenium cannot interact with the pop up.
The result is the HttpWebRequest does not get a response back triggering a WebdriverTimoutException. This results in the session getting cleaned up. This causes a cascade of failures for all other tests in the suite as the session has been terminated.
Environment Info:
Selenium.Webdriver & Seleneium.Support version 3.7.0
IEDriver 3.7.0
Testing in IE 11
I may be late to answer this question, but someone will benefit.
The file(s) in question should be available on the machine (be it local or remote server) that your program is running on, for example, in your /resources directory
On your local machine, this should work.
chooseFileElement.waitForVisible().type("/file/path/filename.jpg");
clickButton("Attach File");
On Remote Server however, you need to associate a new instance of LocalFileDetector to the <input type=file> element.
LocalFileDetector detector = new LocalFileDetector();
File localFile = detector.getLocalFile("/file/path/filename.jpg");
RemoteWebElement input = (RemoteWebElement) myDriver().findElement(By.id("fileUpload"));
input.setFileDetector(detector);
input.sendKeys(localFile.getAbsolutePath());
clickButton("Attach File");
It really depends on how you've written your code. What I would do is when you get down to the end and detect that you've gotten into a bad state, e.g. the File | Open dialog has been left open, close the dialog and start that part of the script over. I'm not sure what start over in your case would mean... maybe it means reload the page and start from there... maybe it means just .sendKeys() to the INPUT again.
You should be able to dismiss the dialog by sending an ESC to the page. You should be able to use .sendKeys() on the BODY tag or whatever.
You should be able to detect the bad state by catching certain exceptions.

How to run an internet browser in the background without window?

How can I run an internet browser with an url, any url I want, and it opens but it opens in background without showing a window?
It should be like a background media player. And if you know how to do that please tell me and tell me how I can mute the browser once starting. I am trying to do this with a batch file.
You can open a hidden window with powershell. You can use powershell commands within cmd or in a .bat file as well. Here's an example:
powershell saps 'https://stackoverflow.com/questions/44642194' -wi hidden
That opens a hidden window of your default browser with the specified link.

check for and close firefox popup with batch file?

I have this simple batch script that opens up a firefox profile
#echo off
start firefox.exe -P default -no-remote
sometimes the profile is already opened and i get this popup.
Is there anyway to check if the popup appeared and click the close firefox button? Or maybe theres a piece of code where i can close the firefox profile and play that in the begining of the batch file so that i know for sure its closed and dont get that popup. Thanks for your help.
Try with sendkeys.bat:
call sendkeys.bat "Close Firefox" "{LEFT}{ENTER}"

Unclosable webpage .bat file

I want to be able to make a .bat or .vbs file that opens a certain website and closes it after a set period of time. I'm trying to get the website to be unclosable until it's manually closed (through task manager) or after a timer of like a minute. Thanks.
You have to open a website in a browsers so you gab to call your browser with a command line argument (in this case the url of the website)
I only know how to do that with Firefox but it should be the same with chrome or IE.
start "" "path to browser" [url or other argument]
^ Title of your window!
Since it's a browser you can only close it manually!

Resources