I tried to run a selenium webdriver script in internet explorer using IE driver server. It launched the browser and home page, but it's not clicking "Next" button and not proceeding to further pages.Can anyone please tell me the reason behind it and what to do to go to further pages.
I tried to run the script in multiple browsers.
#BeforeTest
public void launchBrowser(String browser) throws Exception
{
if(browser.equalsIgnoreCase("FF"))
{
log.info("Launching Firefox Browser");
driver=new FirefoxDriver();
}
else if(browser.equalsIgnoreCase("IE"))
{
System.setProperty("webdriver.ie.driver","D:\\Drivers\\IEDriverServer.exe");
log.info("Launching Internet Explorer Browser");
driver=new InternetExplorerDriver();
}
else if(browser.equalsIgnoreCase("GC"))
{
System.setProperty("webdriver.chrome.driver", "D:\\Drivers\\chromedriver.exe");
log.info("Launching Chrome Browser");
driver=new ChromeDriver();
}
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
There can be following reasons for test failing
IE renders object slow when compared with chrome or fire fox which means your script is trying to click object even its not ready yet so increase time out to 50-60 sec to solve this issue
If you are using xpath then this issue is due to that because IE x path expression is different then chrome and FF
Related
I am not able to do automation testing with Appium server by using Eclipse with Selenium. I have shared below Eclipse error and Appium server logs also. I have shared Eclipse error also as below:
Error: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag
Please check below code in Eclipse:
package tests;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class StartChrome {
public static void main(String[] args) {
// Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "My Phone");
caps.setCapability("udid", "7970dc54"); // Give Device ID of your mobile phone
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "9 PKQ1.180904.001");
caps.setCapability("appPackage", "com.android.vending");
caps.setCapability("appActivity", "com.google.android.finsky.activities.MainActivity");
caps.setCapability("noReset", "true");
// Instantiate Appium Driver
try {
AppiumDriver<MobileElement> Driver = new AndroidDriver<MobileElement>(
new URL("http://0.0.0.0:4723/wd/hub"), caps);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
}
}
It looks like you haven't actually started your Appium server yet. You can't instantiate a new AndroidDriver without starting the Appium server.
Above the line // Set the Desired Capabilities, add this:
// start appium service
AppiumServiceBuilder builder = new AppiumServiceBuilder();
AppiumLocalService _appiumLocalService = builder.UsingAnyFreePort().Build();
_appiumLocalService.Start();
You'll also need to update the line
AppiumDriver<MobileElement> Driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);
to
AppiumDriver<MobileElement> Driver = new AndroidDriver<MobileElement>(_appiumLocalService.ServiceUrl, caps);
That way, you are using the correct service URL that you Appium service was started on.
Additionally, you should also make sure the following settings on your Android device are also enabled:
Developer mode ON -- tap build number 7 times
USB Debugging ENABLED
Select USB configuration -- change from Charging to Picture Transfer Protocol or MIDI
Make sure your device is appearing when you run adb devices command. I only needed to enable the first two options -- developer mode & USB debugging -- to get mine working.
I have developed the embedded jetty server to implement the rest service.
I have setup the eclipse project in the eclipse.
I have written the sample program which returns some details through rest url,
I was successfully compiled the program and created a Runnable jar.
I was successfully able to run the Jar files and the server started and running on the port which i gave ,
I have the testing url
http://localhost:1234/getuser/1
it gave me the user details in the response
<username>test1</username>
I ran the same url with different id no
http://localhost:1234/getuser/2
Again it gave me the same result,
`<username>test1</username>`
So i have restarted the server and then it got me the proper details,
<username>test2</username>
public static void main(String[] args) {
// TODO Auto-generated method stub
ServletContextHandler context = new
ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
Server jettyServer = new Server(1234);
jettyServer.setHandler(context);
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", org.test.test.getuser.class.getCanonicalName());
try {
jettyServer.start();
jettyServer.join();
} catch (Exception e) {
e.printStackTrace();
} finally{
jettyServer.destroy();
}
}
Without restarting the jetty web server how to get the proper results.
Is there any thing i need to add in the code to get it worked.
or any settings i need to do for this auto refresh?
I have found the answer, jetty server was able to refresh automatically, there was a object refresh didnt happened in the back end, resolved it from myside and it worked
I would appreciate if someone could help with the code below
package IEProjects;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class startIE {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver", "C:\\IEDriverServer_Win32_3.3.0\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");
}
}
And am getting the below results
Started InternetExplorerDriver server (32-bit)
3.3.0.0
Listening on port 29209
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unexpected error launching Internet Explorer. Browser zoom level was set to 150%. It should be set to 100% (WARNING: The server did not provide any stacktrace information)
It launches IE and didnt perform the action. Below is what is printed on the IE page
This is the initial start page for the WebDriver server. http://localhost:41380/
The error message is descriptive enough, there is a set of pre-requisites to the IEDriver:
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration
Notice:
The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
I'm trying to use watir-webdriver with IE9 on 64bit Windows 7.
When I try to open a new browser I am getting the following error message, any ideas on a solution?
C:\watir>irb
irb(main):001:0> require "rubygems"
=> true
irb(main):002:0> require "watir-webdriver"
=> true
irb(main):003:0> browser = Watir::Browser.new(:ie)
Selenium::WebDriver::Error::NoSuchDriverError: Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones.
I can use watir-webdriver on the same machine okay with Firefox 4, so I'm guess either its and IE9 issue?
Did you try disabling protected mode as the error message tells you ?
Tools >> Options >> Security >> Untick 'Enable Protected Mode'
This thread on selenium-developers group is relevant to the restrictions with protected mode:
http://groups.google.com/group/selenium-developers/browse_thread/thread/4dd6330f97bd2312/3e904642ac3dac6?q
Also relevant a link to the Watir FAQ.
Try one of these:
Add your defaut homepage (or 'About:Blank' if you start with a
blank page) to the same security group
(e.g. 'intranet' or ''trusted sites')
as the site you are testing; or
Turn off Internet Explorer Protected Mode; or
Change your ruby permissions to "run as administrator"; or
Disable User Access Control
I had same issue, but I have fixed it within the Automation script by setting IE Capabilities. We can change protected mode settings within the script, before launching the browser. You can try the below code:
caps = Selenium::WebDriver::Remote::Capabilities.ie(:ignoreProtectedModeSettings => true)
driver = Watir::Browser.new :ie, :desired_capabilities => caps
When I run WatiN tests on our build server they all throw this InteropServices.COMException:
MyTestClassName.MyTestMethodName:
System.Runtime.InteropServices.COMException : Creating an instance of the COM component with CLSID {0002DF01-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 80004005.
I get the same result wether I run them through TeamCity or I run them manually on the server as an administrator using NUnit GUI (2.5).
This is some sample code:
[TestFixture]
public class MyTestClassName
{
private string pageUrl;
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
pageUrl = ConfigurationManager.AppSettings["SiteURL"] + "/Pages/MyPage.aspx";
Settings.MakeNewIeInstanceVisible = false;
}
[Test]
public void MyTestMethodName()
{
using (var ie = new IE(pageUrl))
{
ie.SelectList(new Regex(#"^*DropDownList1*$")).Option("TheOption").Select();
ie.SelectList(new Regex(#"^*DropDownList2*$")).Option("AnOption").Select();
ie.SelectList(new Regex(#"^*DropDownList3*$")).Option("OtherOption").Select();
}
}
}
Any ideas what it can be?
/Joakim
Try running Visual Studio as Administrator.
I also meet the same problem but more strange for me.
I've got a server only for "UI testing" and for many application de WatiN test runs without any problem.
This error only happens for one application and only in CruiseControl (with nant) but not when runing the test with NUnitGUI...
I Finnaly found a solution this morning: I replaced all my call new IE(); to new IE(true) WatiN release note And didn't get the error anymore.
Another fix is to "Enable Protected mode in IE" like described here
Every time IE.Quit was called by WatiN IE would stop responding and then try to recover. Run as admin fixed the problem for me.
Another comment says:
Try running Visual Studio as Administrator
It is actually NUnit that needs to be run as administrator (at least in Windows 7), but the thinking is correct.
I think that the select list is not yet fully loaded and ready, and this is another symptom of the same problem described in this question:
Access denied error ( Visual Studio and WatiN )