Yesterday Internet Explorer got updated (11.0.44 update), then below code prompts me with the following error not able to get browser.
I have set HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE key of iexplore.exe with 0.
Anyone can help me out?
Code:
String IEDriver_64 = "D:/Tools/IEDriverServer.exe";
System.setProperty("webdriver.ie.driver", IEDriver_64);
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true);
WebDriver driver = new InternetExplorerDriver(capabilities);
//capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
String baseUrl = "https://xxx//member/login.php";
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(baseUrl);
Thread.sleep(1000*30);
System.out.print("driver.getCurrentUrl()1="+driver.getCurrentUrl());
System.out.print("driver.getTitle()1="+driver.getTitle());
System.out.print("-------------1-------------");
String currenthandle = driver.getWindowHandle();
System.out.print("-------------2-------------");
System.out.print("currenthandle="+currenthandle);
Thread.sleep(1000*5);
driver.findElement(By.id("SUBMIT_LOGIN")).click();
Related
I am using the code mentioned below but it is not working Chrome Version 79:
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
//capability.setCapability("pageLoadStrategy", "none");
System.setProperty("webdriver.chrome.driver","driver//chromedriver.exe");
driver = new ChromeDriver(capability);
//driver.manage().deleteAllCookies();
driver.manage().window().maximize();
//Runtime.getRuntime().exec("AutoIT_Exe//AutoIT_Login.exe");
driver.get(url);
You can use switches to ignore such errors
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
driver = new ChromeDriver(capabilities);
I am trying to access the following site and get a registration pop up. In HTML it shows as form type. I tried handling as alert but it is not and I get exception as no modal dialog box opened. I tried window handles. The size of the window handles is only 1.
Please help me, so that, I can click on 'Signin' link on registration form and then login.
Website: http://way2automation.com/way2auto_jquery/index.php
System.setProperty("webdriver.gecko.driver", "C:\\mamtha\\Selenium Practice\\GeckoDriver\\geckodriver.exe");
String URL = "http://way2automation.com/way2auto_jquery/tooltip.php";
WebDriver driver = new FirefoxDriver();
driver.get(URL);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(3000);
Set <String> winhandle = driver.getWindowHandles();
System.out.println(winhandle.size());
WebElement sigin = driver.findElement(By.xpath("//a[contains(text(), 'Signin']"));
sigin.click();
driver.findElement(By.xpath("//input[#name = 'username']")).sendKeys("myusername");
driver.findElement(By.xpath("//input[#name = 'password']")).sendKeys("password");
driver.findElement(By.xpath("//input[#class = 'button']")).click();
Modal dialog box is getting opened in the same page itself.so, you don't want to use the window handles. You need to move the focus to the modal dialog box first and then directly access the required element(add some explicit wait condition as well).
Working Code:
System.setProperty("webdriver.gecko.driver", "C:\\mamtha\\Selenium Practice\\GeckoDriver\\geckodriver.exe");
String URL = "http://way2automation.com/way2auto_jquery/tooltip.php";
WebDriver driver = new FirefoxDriver();
driver.get(URL);
driver.manage().window().maximize();
//Explicit wait is added after the Page load
WebDriverWait wait=new WebDriverWait(driver,20);
wait.until(ExpectedConditions.titleContains("Welcome"));
WebElement modalDialogBox=driver.findElement(By.className("fancybox-skin"));
modalDialogBox.findElement(By.xpath(".//a[text()='Signin']")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("fancybox-skin")));
WebElement loginDialogBox=driver.findElement(By.className("fancybox-skin"));
loginDialogBox.findElement(By.name("username")).sendKeys("myusername");
loginDialogBox.findElement(By.name("password")).sendKeys("987654321");
loginDialogBox.findElement(By.className("button")).click();
Try the following code.
String URL = "http://way2automation.com/way2auto_jquery/tooltip.php";
WebDriver driver = new ChromeDriver();
driver.get(URL);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().maximize();
Thread.sleep(5000);
WebElement sign=driver.findElement(By.xpath("//p[#class='text_popup']/a[contains(text(),'Signin')]"));
sign.click();
Thread.sleep(5000);
driver.findElement(By.xpath("//div[#id='login']/form/fieldset[1]/input")).sendKeys("myusername");
Thread.sleep(5000);
driver.findElement(By.xpath("//div[#id='login']/form/fieldset[2]/input")).sendKeys("password");
driver.findElement(By.xpath("//div[#id='login']/form/div/div[2]/input")).click();
Not able to capture screen shots for electron application using java .
Here is my code for webdriver setup.
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("/Applications/betlite.app/Contents/MacOS/appname");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
driver = new ChromeDriver(capabilities);
Using following method to capture screen , it do work for traditional ChromeDriver .
public static void captureScreenMethod() throws IOException, InterruptedException
{
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
Thread.sleep(4000);
FileUtils.copyFile(scrFile, new File("path_of_file/screenshot.png"));
}
I am getting following error -
org.openqa.selenium.WebDriverException: unknown error: cannot get
automation extension from unknown error: page could not be found:
chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
I am using MAC OS
Thanks
I am using this code to launch Chrome with WebDriver.
System.setProperty("webdriver.chrome.driver","E://ChromeDriver//chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://google.com");
Please help to open browser in current chrome session. Please use JAVA for solution
I have try this code to open new tab. #niazi, it will help you.
Code:
System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://google.com");
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,"t");
driver.findElement(By.tagName("body")).sendKeys(selectLinkOpeninNewTab);
Thread.sleep(2000);
ArrayList<String> tabs2 = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(tabs2.get(1));
driver.get("http://facebook.com");
WebDriver driver = new ChromeDriver();
It means open new Chrome browser. Once you have to open new browser window.
EDIT as per your comment
System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe");
WebDriver driver = new ChromeDriver(); driver.manage().window().maximize();
driver.get("http://google.com");
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,"t");
driver.findElement(By.tagName("body")).sendKeys(selectLinkOpeninNewTab);
Thread.sleep(2000);
ArrayList<String> tabs2 = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(tabs2.get(1));
driver.get("http://facebook.com");
I am using the below code to create a firefox web driver using Selenium Java API.But it neither create firefox instance nor gives any error message.Control comes directly to finally block after some time.
Java APi used - 2.46.0
Firefox version - 32.0.1
JRE -1.8.25
Can some one help me to debug the issue?
code -
WebDriver driver;
try{
ProfilesIni profile = new ProfilesIni(); //ignore ietab+options
FirefoxProfile defualtProfile = profile.getProfile("default");
//defualtProfile.setAcceptUntrustedCertificates(false);
DesiredCapabilities capabilities = DesiredCapabilities.firefox(); //To over come ssl certificate error
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(FirefoxDriver.PROFILE,defualtProfile);
Thread.sleep((long)(2000*Math.random()));
driver=new FirefoxDriver(capabilities);
return driver;
}
catch(Exception ex)
{
logger.error("Exception - > " + ex.toString());
return null;
}
finally
{
logger.info("End");
}
There is simple code to initialize firefox driver. Try below code and let me know.
For more information refer this.
DesiredCapabilities dc=DesiredCapabilities.firefox();
FirefoxProfile profile = new FirefoxProfile();
dc.setCapability(FirefoxDriver.PROFILE, profile);
Webdriver driver = new FirefoxDriver(dc);
return driver;