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.
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 the following code:
public class LoadBrowserAndSurf {
#Test
public void loadAndSurf() {
System.setProperty("webdriver.chrome.driver", "D:\\Desktop\\Automation Requirements\\chromedriver\\chromedriver.exe");
String proxyString= "13.228.117.219";
Proxy proxy = new Proxy();
proxy.setHttpProxy(proxyString);
DesiredCapabilities browserProxy =new DesiredCapabilities();
browserProxy.setCapability(CapabilityType.PROXY,proxy);
WebDriver wd = new ChromeDriver(browserProxy);
wd.get("http://www.globe.com.ph/");
}
}
In eclipse oxygen this code is able to initiate the driver version, however it is not accessing the proxy.
When try I the same code in the IntelliJ editor, it strikes out the ChromeDriver in the driver object initiation line i.e:
WebDriver wd = new ChromeDriver(browserProxy);
And states message as:
ChromeDriver(org.openqa.selenium.Capabilities) is depricated
Is there a way I can add this proxy in the driver instance when it launches in runtime?
While executing this code, it generates an error for chrome which timed out waiting for driver server to start.
package pkg;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ClassLogin {
private WebDriver driver;
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
driver = new ChromeDriver();
driver.get("www.xyz.com");
driver.manage().window().maximize();
}
}
webdriver.chrome.driver needs to be set to a path to chromedriver.exe and not chrome.exe.
You may need to download ChromeDriver - WebDriver for Chrome and then set there system property appropriately.
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
I'm using Netbeans 7.1.2 on Mac OS X Lion 10.7.3.
I have a simple java server (using netty) project and after I build and run the project then try to stop the running by Run->Stop Build it does not terminate the java server process.
For example, my server app uses port 8080 and even after I stop running from the netbeans the port 8080 is in use and the app keeps running. I have to manually kill the java process from activity monitor.
What's the correct procedure to end the running app started by Netbeans?
Greatly appreciate your help. Thanks in advanced.
Have a look at the documentation: http://netty.io/docs/stable/guide/html/. Scroll down to section 9. Shutting Down Your Application.
Your main app ahs to look something like:
package org.jboss.netty.example.time;
public class TimeServer {
static final ChannelGroup allChannels = new DefaultChannelGroup("time-server"(35));
public static void main(String[] args) throws Exception {
...
ChannelFactory factory = ...;
ServerBootstrap bootstrap = ...;
...
Channel channel = bootstrap.bind(...);
allChannels.add(channel);
...
// Shutdown code
ChannelGroupFuture future = allChannels.close();
future.awaitUninterruptibly();
factory.releaseExternalResources();
}
}
You handler needs:
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) {
TimeServer.allChannels.add(e.getChannel());
}
You have to:
1. Store all your channels in a ChannelGroup
2. When shutting down, close all channel and release resources.
Hope this helps.