RemoteWebDriver IE Clicking Links doesn't work - java

I am using the RemoteWebDriver and trying to execute a couple of UI tests on a remote machine under Internet Explorer:
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), DesiredCapabilities.internetExplorer());`
driver.get("http://bing.com");
driver.findElement(By.id("sb_form_q")).sendKeys("Cheese");
driver.findElement(By.id("sb_form_go")).click();
Using the following code works in FireFox and Chrome but not in IE. IF I run a plain web driver on my local machine it works fine. Does anyone know why this is the case or if there is a work around?
I am using Selenium-Server-Standalone-2.8.0 and the Selenium-Java-2.8.0 client drivers.
Thanks in advance.

I had problems with clicking using RemoteWebDriver and IE capabilities. I solved it by using sendKeys(Keys.ENTER) for links/buttons and sendKeys(Keys.SPACE) for radio buttons/checkboxes.

try with submit() instead of click() it should work.

Related

In parallel execution, safari browser navigate to url with out login page automatically

I am using selenium web driver 2.48 and safari driver 2.48 and safari version 8.0.8
I am facing a problem on running my test execution in safari driver.The problem is
"In parallel execution, if in one safari window,login is successfull, than in other
safari windows, this login page is not shown,
that means safri navigate to url with
out login as one safari window already complete login."
and for this reason, i am facing below issue in parallel execution:
"CSRF verification failed.Request aborted"
I want like that for parallel execution:
if five safari browser window open, in each window, login page will be appeared.
In a sense, each safari driver instance will not share other safari driver
instances resources or any other thing
I have changed safari preferences settings but its not helping.
Is there any best way to declare safari driver or i need to add any desired capabilities or
any other things in safari preferences or any any good suggestion.
please and thanks.
i am using the following code:
SafariOptions safariOptions = new SafariOptions();
safariOptions.setUseCleanSession(true);
DesiredCapabilities dc = DesiredCapabilities.safari();
dc.setCapability(SafariOptions.CAPABILITY, safariOptions);
currentDriver = new SafariDriver(dc);
Set<Cookie> cookies = currentDriver.manage().getCookies();
currentDriver.manage().deleteAllCookies();
if(!cookies.isEmpty())
{
Iterator<Cookie> iter= currentDriver.manage().getCookies().iterator();
while(iter.hasNext()){
Cookie C = iter.next();
}
cookies.clear();
}
I personally have not used safari before. And as you said that the behavior in all other browsers are as you expect it to be. I would like you to try the following.
There is a way by which you can specify the profile of the driver instance to be used. I would suggest you to create separate profiles for each instance and try out . How to do that is explained in this answer. This answer explains how to use same profile each time . You need to use a different profile each time. ( Which happens by default in chrome not sure why it wouldn't for safari )

When i run selenium webdriver code Firefox webdriver not starting through given webaddress

When i tried to start on Firefox web driver its not starting its showing firefox default page
WebDriver dr = new FirefoxDriver();
dr.get("https://www.google.co.in/");
dr.manage().window().maximize();
its not starting its showing firefox default page
Below i attach output image screenshot
https://www.mozilla.org/en-US/firefox/43.0.4/firstrun/learnmore/
Firefox is one of the most compatible browsers with selemium, and at the same time, is one of the least compatible.
I say this because if you do not have the correct version of the selenium library to go with the version of firefox you are running, or vice-versa, it will always fail.
I would start by attempting to switch to a different version of Firefox. Selenium version 2.48.0 supports Firefox versions 24-41, so if your firefox version does not fit within that range, it is more than likely the problem.
I faced the same issue. The solution to this problem is to update the selenium version. When the page u mentioned i.e https://www.mozilla.org/en-US/firefox/43.0.4/firstrun/learnmore/ opens on firefox launch go to Options -> Addons -> Extensions. You will be able to see the Error there. I got "Forefox Webdriver could not be loaded and is disabled".
This was on Firefox 43 with selenium 2.44. Updating to selenium 2.51 rectified the issue.
Sorry, I cannot comment yet but I would like to help. I got the similar issue when I used selenium webdriver integrated in my python script. The problem was with credentials (particularly with the SSL protocols while declaring a new webdriver object). The code I used looked as the following:
driver = webdriver.PhantomJS(executable_path = "/opt/local/bin/phantomjs", service_args=['--ignore-ssl-errors=true'])
As you can see I use a key that ignores ssl errors. This solved my issue, so I am not sure what platform you use to write the code but hope you can find the similar call for the object.
I found the way how people handle untrusted certificates here. Particularly, for FireFox:
//It creates firefox profile
FirefoxProfile profile=new FirefoxProfile();
// This will set the true value
profile.setAcceptUntrustedCertificates(true);
// This will open firefox browser using above created profile
WebDriver driver=new FirefoxDriver();
driver.get("pass the url as per your requirement");
Hope it helps you!
Best.
-Petr.
Try this.. This will resolve the issue..
FirefoxProfile fpi = new FirefoxProfile();
fpi.setPreference("browser.startup.homepage_override.mstone", "ignore");
fpi.setPreference("startup.homepage_welcome_url.additional", "about:blank");
wd = new FirefoxDriver(fpi);
wd.get("http://www.google.com");
if you want to over-ride the properties of firefox, then,
1.first to find the list of browser properties, type "about:config" in the address url
2.use, setPreference method to set/assign the values..

Selenium Webdriver (Java) connect/interoperate with a Firefox extension/plugin

i am looking for a way to connect out of the Selenium Webdriver to a Firefox extension/plugin.
I want to start a function from the firefox extension out of the api of the selenium Webdriver. Could this be possible?
I know that i can call javascript code which is inside a page, but not inside a firefox extension.
If it is not possible with selenium webdriver, is there another way to connect, maybe with java?
Thanks a lot for your help!
One of way, how you could do this, is:
Create firefox profile and name it somehow you know what it is. e.g. SELENIUM
Install addon to this profile. In general, make that profile suitable for the tests.
When initializing the Webdriver:
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile desiredProfile = allProfiles.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(desiredProfile);

Using Selenium 2 RemoteWebDriver with ChromeDriver

I searched for an answer to my question here and on the web but couldn't find anything that was helpful to me. Hopefully this isn't too dumb of a question.
I'm trying to get Selenium 2 to work using various browsers. I am using a Mac as a hub and a node and a Windows pc as a node. My problem is with Chrome. I want to initiate the Java code on the Mac and have the Selenium tests run on the Windows pc. To get Chrome to run on localhost I have the following code:
System.setProperty("webdriver.chrome.driver", "Users/xxxxx/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
This opens up Chrome on the hub/node Mac. How do I get it to open up on the Windows PC? Can I pass anything into the ChromeDriver() class?
I've tried using RemoteWebDriver, and have the following:
System.setProperty("webdriver.chrome.driver", "/Users/xxxxx/chromedriver");
DesiredCapabilities cap = DesiredCapabilities.chrome();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:9515/wd/hub), cap);
driver.get("http://www.google.com");
The code compiles and executes, but Chrome never comes up. I don't get any errors. Note that I'm initiating the RemoteWebDriver on localhost and Chrome still doesn't work. Nothing changes if I change the URL to the IP of the Windows PC. I'm either doing something wrong with the RemoteWebDriver or I need to pass parameters to ChromeDriver. Please help.
Found the answer after a bit more searching. Turns out that the URL of the remotewebdriver needed to be only localhost:9515 without /wd/hub. Also, if running on another machine, make sure to start up chromedriver on that machine and point webdriver.chrome.driver to the location of chromedriver.

Can't test a remote HTML/CSS/JS/Java website with Cucumber + Selenium Webdriver + Chrome + Capybara

I'm trying to test with Cucumber + Selenium + Capybara a remote HTML/CSS/JS website which uses a Java .
The website works fine on the Chrome browser, but when I launch my test, the Chrome browser is launched on the website, but the Java applet is not loaded at all.
Looks like the Chrome browser environment launched by Webdriver does not load any third party chrome plugins like Java.
Is there any way to circumvent this ?
Thanks in advance, best regards
Geoffroy
You can load a custom profile with the following code:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--user-data-dir=/path/to/profile/directory"));
WebDriver driver = new ChromeDriver(capabilities);
See the selenium chrome documentation: http://code.google.com/p/selenium/wiki/ChromeDriver
You can maybe try Selenium Remote Control instead of Webdriver. I haven't personally tried Selenium RC with third party tools, but it could an option to try while you're looking for alternatives.

Categories

Resources