How to click device Back button - selenium-webdriver

I am not able to click device back button using selenium Webdriver + AndroidDriver
Below is the code which I am using:
((AndroidDriver<AndroidElement>) driver).pressKeyCode(AndroidKeyCode.BACK);
gson 2.6.2
Java client 5.0.1
Selenium server standalone 3.6.0

Try this:
driver.navigate().back();

Activity activity = new Activity("appPackageName", "appActivityName");
activity.setAppWaitPackage("setWait");
activity.setAppWaitActivity("setWait");
activity.setStopApp(false);
((AndroidDriver) driver).startActivity(activity);
The above code worked for me.

Related

Browser versioning problem for selenium automation testing with google chrome

When I want to send a key on google.com using selenium automation testing with google chrome then I ahve faced a error like the picture and code is
public ActionResult selenium()
{
IWebDriver webDriver = new ChromeDriver();
webDriver.Navigate().GoToUrl("https://www.google.com/");
webDriver.FindElement(By.Name("q")).SendKeys("Selenium");
return View();
}
you need to change ChromeDriver version bcs you have 85v and mybe your browser is with another version you need to check if the browser is a 85 version if it not desanstaled the browser and install version 85

Selenium Webdriver Node js

Puppeteer has connect function to connect with existing browser instance but in selenium ,how to connect to a existing instance of IE browser using selenium(webdriver) in javascript?
You can't do that because that function is for chromeDriver only

Robot framework - Selenium - ChromeOptions "Prompt For Download" not working when downloading a file

I'm using robot framework with selenium for automating my web application.
I'm trying to open chrome browser and download a XML file and then parse it from the results folder ${OUTPUT_DIR}.
Every time I'm trying to download any file, chrome browser shows the windows prompt to download the file. I tried using the chrome options to disable the prompt, but it is not working. Please find the piece of code used to invoke chrome browser.
When tried using the regedit - PromptForDownloadLocation variable, it is working fine.. but I want to manage this using chromeOptions
Could you please help me with this.
ChromeDriver version : 79.0.3945.36
Robotframework - SeleniumLibrary version : 3.3.1
Create Webdriver and Open Browser
${CHROME_OPTIONS} = evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${prefs} = create dictionary download.prompt_for_download=${FALSE} download.directory_upgrade=${TRUE} download.default_directory=${OUTPUT_DIR} safebrowsing.enabled=${TRUE}
call method ${CHROME_OPTIONS} add_experimental_option prefs ${prefs}
create webdriver Chrome chrome_options=${CHROME_OPTIONS}

How to close firefox browser in selenium 3.0.1

Firefox : 50.0.1, GeckoDriver :13, selenium 3.01, IDE: Eclipse, Programming language : Java
Using below code :
System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe);
WebDriver driver = new FirefoxDriver();
driver.get("https://www.youtube.com/");
driver.close(); Or driver.quit()
In driver.close() the browser is not closed
In driver.quite() the browser is closed and Firefox crashed.
Getting Error: "plugin container for FireFox has stopped working."
Please let me know any solution
Steps you can try:
Uninstall any plugins in the Firefox browser.
Use the 64-bit version of geckodriver for 64-bit Firefox, similarly, 32-bit geckodriver for 32-bit Firefox.
I have tried the code in the same environment, and driver.quit worked for me. driver.close still not closing the browser.
You should always use driver.quit() when you want to close browser and not just one tab.
This exception you get is unfortunately known issue when quitting geckodriver firefox instance, see this links for details.
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/7506
https://bugzilla.mozilla.org/show_bug.cgi?id=1027222
You can create a new firefox profile steps can be found here!
In your code use this new profile created.
WebDriver webdriver;
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("myProfileName");
webdriver = new FirefoxDriver(myprofile);
Now webdriver.quit(); will close the firefox browser after the test has run.
This seems to be a problem with the geckodriver.
The workaround which worked for me was to install the older version of geckodriver, 0.20.1, which you can download here: https://github.com/mozilla/geckodriver/releases/tag/v0.20.1

When run selenium webdriver script it redirecting to first run page https://www.mozilla.org/en-US/firefox/44.0.2/firstrun/learnmore/

I am trying to run my selenium web driver script but it redirecting to first run page of firefox .
enter image description here
I am using firefox version 44.0.2.
How to disable it and run my script.
I have referred link Firefox webdriver opens first run page all the time but didn't get the solution and also i have updated selenium web driver to version 2.52 but didn't work at all
Please help with your answer
Thanks
I think that's happening because the new issue occurs with latest update of Mozilla firefox.
It's happening with me too.
To overcome from this issue you need to setPreference as xpinstall.signatures.required", false to firefox Profile and then pass it to driver object
firefoxProfile.setPreference("xpinstall.signatures.required", false);
Below code is working fine for me.
static WebDriver driver=null;
public static void main(String[] args) {
final FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
driver = new FirefoxDriver(firefoxProfile);
driver.get("https://www.google.de/");
Hope it will help you :)

Resources