I use my WebDriver, with FireFox.
I have an elemnt: //input[#class="uploadFiles"], when I click on it by:
driver.findElement(By.xpath("//input[#class="uploadFiles"]")), a windows of upload a file (Windows OS's window) is opened, but the test doesn't continue to the next line, and get stuck.
Any help?
Webdriver doesnt interact with os level dialogs and that's the reason it doesnt continue to the next line. Here's something to help you : http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_Does_WebDriver_support_file_uploads?
No you cant do it with WebDriver as niharika_neo answer but you can do next:
string filepath = "my local path";
_driver.FindElement(By.Id("attachments")).SendKeys(filepath);
_driver.FindElement(By.Id("attachments")).SendKeys(Keys.Return);
You can't interact with OS level Windows directly. You can go through the path given by niharika_neo or else you can use Auto IT tool for handling the OS level windows. The best option is to use Auto IT tool.
I faced the same problem with FF, then I found that it was specific to the FF version I am using. I installed and ran the tests on FF 11, and I was able to successfully runt he tests. Try changing the version of FF that you are using.
Related
After update chrome browser to the Version 62.0.3202.75 (Official Build) (64-bit)
spec symbols are missed in set text and browser settings page is opening unexpectedly on enter spec symbol or capital letter.
Tests are based on WDIO http://webdriver.io/
For example if I execute
browser.setValue(selector,"Text #1");
the result in the input will be: "Text 1" and 2 opening of settings Page
Affected MAC OS only, no issue on Windows OS
Please advise how to fix, thanks for sharing any experience.
Sounds like a bug that you should post into the github section of webdriver.io
Please check if you use the latest version of your webdriver & selenium.
However you can maybe use http://webdriver.io/api/protocol/keys.html
to enter keys you currently can´t use.
Issue was in chromedriver
https://bugs.chromium.org/p/chromedriver/issues/detail?id=2113
Fixed after update chromedriver to 2.33 version and update chrome browser to 62.0.3202.94 version
When I run my Selenium tests with Firefox 28.0 I get:
"An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code
Additional information: Unable to determine the current version of FireFox using the registry, please make sure you have installed FireFox correctly"
I successfully ran tests yesterday with Firefox.
I think Firefox auto-updated to 28.0 since yesterday.
Today I'm getting the above error.
I uninstall Firefox and reinstalled but I still get the same exception.
Selenium 2.40
Firefox 28.0
Gallio and MbUnit 3.4
Any ideas on how to fix? I suppose I could switch to IE for testing.
Ed
The error was generated on the call to FireFoxBinary() constructor.
DriverObj = New FirefoxDriver(New FirefoxBinary(), New FirefoxProfile(), TimeSpan.FromMinutes(10))
The call to FirefoxBinary worked for three weeks so I'm not sure why it decided to fail yesterday. Perhaps it was the auto-update by Firefox from 27 to 28.
The solution was to add the file path to the Firefox binary:
DriverObj = New FirefoxDriver(New FirefoxBinary("C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"), New FirefoxProfile(), TimeSpan.FromMinutes(10))
One possible solution to this would be to manually add the registry key that is being searched for. Normal FireFox builds (non ESR) appear to place a key titled "CurrentVersion" with a string value of the version in the
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla FireFox
directory. Testing has shown me that when I place a key similar to this but with a string value of the ESR version installed on my system in this location Selenium will work. The caveat is that as this question is rather old I have tested with Selenium 3.0.1. If you would like to try this the your registry key should look like this without the quotes:
Name = "CurrentVersion" and
Value = "45.6.0 ESR (x86 en-US)"
Please keep in mind that this solution will get you by in a pinch, but each time ESR updates you will need to go in and update the key value.
This was driving me mad, until i finally cracked it, here's the code that fixed mine:
var options = new FirefoxOptions();
options.BrowserExecutableLocation = #"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
IWebDriver driver = new FirefoxDriver(options);
Since updated to Firefox 12, every time I launch Firefox with a particular profile with Selenium (in python and Mac OS 10.7) it pops up the "checking compatibility of add-ons" dialog, and sometimes this dialog would stay up forever and I have to force-quit it. After forcing quit it, a new instance of the Firefox would continue to launch and finishes the rest of the Selenium script successfully though.
I have tried setting extensions.checkCompatibility to false. This fixed it if I launched Firefox normally, but not if I launch it with Selenium. Any idea on how to suppress this dialog? Thanks!
This dialog is shown only once whenever Firefox is updated. The reason it is shown each time for you is probably that Selenium creates a new profile each time. If you set extensions.lastAppVersion preference to "12.0" (or whatever the current Firefox version is) then Firefox will no longer think that it has been updated and won't show this dialog. However, it should be easier to add a extensions.showMismatchUI preference and set it to false, this will suppress this dialog (but not the other upgrade actions).
Side-note: extensions.checkCompatibility preference no longer does anything starting with Firefox 3.6, it is a version-specific preference in the current Firefox versions. So you would have to set extensions.checkCompatibility.12.0 preference instead. That disables compatibility checking for extensions completely however, not just the dialog you are concerned about.
I have tried setting extensions.checkCompatibility to false. This fixed it if I launched Firefox normally, but not if I launch it with Selenium.
The reason it won't when you launch it with Selenium is the Firefox Driver will create a temporary profile in the temporary files directory, slowing down tests and taking up unnecessary space.
Create a profile for your test purposes and set what you need. Full instructions to create the SeleniumProfile can be found at https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles
In Java I have the following:
protected WebDriver createFirefoxDriver() {
File proFile = new File("C:\\Users\\<username>\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\xxxxxx42.SeleniumProfile");
FirefoxProfile ffProfile = new FirefoxProfile(proFile);
WebDriver ffDriver = new FirefoxDriver(ffProfile);
return ffDriver;
}
Do this to remove the "checking for addon's compatibility" Dialog. This is based on the Windows operating system..
Create a temporary FF Profile and start the server with that profileas shown below.
java -jar selenium-server-x.x.x.jar -firefoxProfileTemplate "/path/to/the/temp/profile"
Now use the following code.
import com.thoughtworks.selenium.*;
public class Test {
public static void main(String ar[]) {
Selenium sel = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/");
sel.start();
}
}
Now in the Run command type "%TEMP%" and you can see there a folder with same name as the selenium session. Copy the folder contents and replace them with your temp profile Contents.
Follow the steps below to remove the Addons compatibility.
1 . Create a new FF Profile
2 . Set the FF Profile as per required settings
3 . Just run a sample program of selenium such that it invokes firefox.
4 . Now you can find a folder with the same name as Selenium Session created somewhere in your sytsem. ( Most probably in the directory where the Temporary Content is saved)
5 . Copy the folder contents and replace them with the newly created profile.
Now you can use the newly created profile whenever required. Whenever FF is updated , always check whether the existing addons are compatible with the Existing version by once invoking firefox with the Profile.
I have been developing an AJAX application using jQuery and Microsoft Seadragon technology.
I need to have access to the html5 canvas function toDataURL.
With Google Chrome, the same origin rule applies to this function which means that a page run locally (with the file:/// in the URL) failed to satisfy the same origin rule and an exception is thrown.
With Chrome 7, starting the application with --allow-file-access-from-files option, allows to call canvas.toDataURL() from local files.
However, it seems that starting the Chrome Beta 8 with the same option (--allow-file-access-from-files) does not allow the call canvas.toDataURL() on the local file.
Does Chrome gave up on the --allow-file-access-from-files option or it has just been disabled since it is a Beta release and not a full release?
Thanks!
Looking at the issues for this shows that the whole --allow-file-access-from-files thing was rushed.
"Firefox does it.."
"How can we do it?"
some time passes
"Here are the patches"
"Passes! On trunk wonder what happens in the next dev release"
"Ahhh it's broken" "Use the command line option" "ok"
"We shipped!"
"WTF guys? You broke all my stuff! Why didn't you tell us earlier?"
silence
On to your Problem
Indeed it seems that this is something special to the beta, I'm using Chrome 8.0.552.5 dev here and --allow-file-access-from-files works like expected, I've also tested this with Chromium 9.0.592.0 (66889) were it also works as expected.
I suspect there have been some changes on the dev branch. Unfortunately, finding something on chromium's issue tracker is nearly impossible.
Did you close all chrome instances before opening with the command line argument? You have to do that to make that parameter work.
To summarize all answers so far.
Before running chrome, make sure there are no chrome processes running.
Windows
-allow-file-access-from-files
(with one dash)
Linux
--allow-file-access-from-files
(with two dashes)
I've found a way around the issue using a JavaScript/Flash approach. If flash is compiled in the Local Only security sandbox, it has full access to local files. Using ExternalInterface, JavaScript can request a Flash Application to load a file, and Flash can pass the result back to JavaScript.
You can find my implementation here: https://code.google.com/p/flash-loader/
The trick that woked for me is that you have to give the absolute path of the file and not just file name in your HTML code. e.g file://... instead of direct name even though you are accessing the file in the same directory. It will work!
I am trying to get selenium tests to run. Yet every time I try to run a tests that should run IE I get a error on line 863 of htmlutils.js It says that I should disable my popup blocker. The thing is I went to IE tools-> turn of popup block.
So it is disabled and I get this error.
Is there something else I need to disable. I actually don't even know what version of Internet explorer it is running since I am using Windows 7 Pro 64bit version. So when I do use IE I use 64bit version but I am under the understanding if the site or something like that does not support 64bit it goes to 32bit.
So not sure what I need to do it to make it work.
This is the lines where it does
function openSeparateApplicationWindow(url, suppressMozillaWarning) {
// resize the Selenium window itself
window.resizeTo(1200, 500);
window.moveTo(window.screenX, 0);
var appWindow = window.open(url + '?start=true', 'selenium_main_app_window');
if (appWindow == null) {
var errorMessage = "Couldn't open app window; is the pop-up blocker enabled?"
LOG.error(errorMessage);
throw new Error("Couldn't open app window; is the pop-up blocker enabled?");
}
Where is this log.error message stored? Maybe I can post that too.
I had a similar problem on Vista and IE8
I would get the same error message
Couldn't open app window; is the pop-up blocker enabled?"
Running my remote control as Admin wasn't an option for me, and also a poor idea from a security perspective.
So in the end I manage to solved this by changeing browser from "*ietha" to "*iexploreproxy"
grid_configuration.yml
hub:
port: 4444
...
- name: "Internet Explorer 8 on Vista"
browser: "*iexploreproxy"
...
Alternatively, you can change browser string from the code:
ISelenium selenium = new DefaultSelenium("localhost", 4444, "*iexploreproxy", "http://www.google.com/");
Works like a charm.
The only question remaing is if this somehow affects the outcome of the test cases. So far no, but I'll update this answer in case that would happen.
I ran into this on Windows 7 64bit.
My solution was:
Disable popup block. - Select "Tools/Popup Blocker/Turn off pop-up blocker"
Disable IE protected mode. - Untick "Tools/Internet Options/Security/Enable protected mode"
It'd be better just to disable protected modes for known trusted hosts/addresses. I'll leave that as an exercise for the reader.
I was experiencing the same problem. I ran the Selenium RC server as an administrator and everything worked fine.
I, too, am experiencing this very problem on a Windows 7 64bit box, trying to run Selenium on it to test and ASP .Net MVC application, written in C#.
I am still trying to work out the answer for myself, but I thought I'd post here to tell you of a little progress I have made in getting something to work, albeit in Firefox instead of IE.
Here's the line I changed:
selenium = new DefaultSelenium("localhost", 4444, "*chrome C:/Program Files (x86)/Mozilla Firefox/firefox.exe", "http://www.bbc.co.uk/");
I would ideally like for this to work in Internet Explorer 8, but if for the moment, I can begin getting tests working and later change over to use IE again, then great.
Hope this helps for your problem with it all.
I had the same problem on Windows 7 64bit IE8. The first step was to disable the IE popup blocker. Then, I got a message in the status bar saying that "Pop-ups were blocked on this page. Press the 'Ctrl' key to allow the pop-ups".
It turns out that the Google Toolbar was providing this feature. Disabling it solved the problem. View > Toolbars > Google to toggle.
John.
If you happen to be doing this from JavaScriptMVC, there is a reference you need to change in \jmvc\plugins\test\drivers\selenium.js:
1) Change iexplore to iexploreproxy and you should get better results:
msie : (/iexploreproxy/i).test(browserStartCommand),
2) At this point, you'll find that you still get the popup error, but a separate instance of IE has started. Leave that IE window open and restart the tests, but not Selenium.
3) Next, the windows should show up in the right place, but IE gives the annoying block active content warning. Allow the content to run and restart the tests, but not Selenium itself.
This is super clunky, but it at least gets you past that part. If I find more methodical ways to do these things I'll update as needed.
I have had the same problem and have found another solution which works for me. Just use the *iexploreproxy setting in the browserString.
I used:
selenium = new DefaultSelenium("localhost", 4444, "*iexploreproxy C:/Program Files/Internet Explorer/iexplorer.exe", "http://www.bbc.co.uk/");
I hope that works for others too :)
You can start the test when you disable the Security mode of Internet. Don´t know the correct name for it, but in dutch it is beveiligde modus.
I tried modifiing the security settings to dublicate this security mode, but couldn´t find the correct setting for it. It must therefor block more then you can set manually.