Taking screenshot on mobile device using Selenium Webdriver + Java - selenium

If I connect my desktop as a hub and a mobile device (ios or android) as a node, will I be able to take a screenshot of a web page on my mobile from the desktop? Can I do it with Selenium Grid + Appium or is any other feature required.
Please advice

Yes, you can do it with Appium or Selenium Grid + Appium. The below code will capture the screenshot and save it as screenshot.jpg
WebDriver driver1 = new Augmenter().augment(driver);
File file = ((TakesScreenshot)driver1).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(file, new File("Screenshot.jpg"));

Related

Is it possible to run 1 chrome driver and 1 android driver at the same time? Selenium | Appium

To log in to the app that I am testing you need to log in via browser and then get a code. Using the code you need to input this on the android device.
is it possible to have 1 chrome driver running and 1 android driver running at the same time?
I am using Selenium and Appium

Does WebDriver Manager also working for Appium?

Is there any Appium manager like the webdriver manager for using? since the appium is implements the Webdriver so..is it there?
Or maybe there is option to use it for Appium drivers too? (Android driver - IOS driver)
Thank you
you don't need to download a "driver" for appium. The drivers comes with the appium package for hybrid and native app testing.
so once you initialize the driver capabilities , appium will automatically install the reuired driver on the device and allows appium server to communicate with the device through xcuitest or uiautomator apis

Mobile browser automation

can we automate mobile browsers without using any emulators or real devices and directly using a web browser?
I know we can use appium to test mobile browsers but for that, we need to have either emulator or real device
I have a web test framework and I want to use the same for mobile browser testing
Yes, you can do it with web browser, using selenium, only you should do to set the dimension size of your mobile:
for example: driver.manage().window().setSize(new Dimension(800, 600));
Potentially yes. However, with a lot of limitations and extra efforts.
You may use the Chrome Dev Tools Mobile Emulation for that:
See this article for details
Selenium allows for remote automation and is supported by both chrome and firefox browsers. Steps for chrome automation in android are:
Enable usb debugging in phone and connect it to pc or laptop
Install python and selenium and android sdk in pc or laptop
adb start-server
adb shell su -c chmod 777 /data/local
./chromedriver
Above commands will display a port number. Just note it down as it will be required further.
Then start automation. Below is small example:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option('androidPackage', 'com.android.chrome')
driver = webdriver.Chrome('./chromedriver', options=options)
driver.get('https://google.com')
driver.quit()
OR
from selenium import webdriver
capabilities = {
'chromeOptions': {
'androidPackage': 'com.android.chrome',
}
}
driver = webdriver.Remote('http://localhost:9515', capabilities) # Specify your port number value
driver.get('http://google.com')
driver.quit()
Both google chrome stable and beta apps available from play store are supported.
Same can be done with firefox and gecko driver. Just change Chrome in above code worh Firefox and chromedriver with geckodriver.
Hope it helped you.

Automate Opera Mini Tests via Appium/Selenium

I have researched how to test mobile web apps via Appium (to use the mobile sdk)
The achieve automation of opera browser tests, one can use selenium / appium with the opera chrome or presto drivers (imported libraries)
However there is no documentation with regards to running automation on opera mini applications.
Does anyone know if this is possible? Has anyone successfully used Apium to test Opera Mini?
Though it is not supported out of the box by Appium (CHROME, CHROMIUM, SAFARI are listed), you can use operachromiumdriver:
desired_caps['chromedriverExecutable'] = '/absolute/path/to/operadriver'
desired_caps['app'] = os.path.abspath('opera-browser.apk')
desired_caps['appPackage'] = 'com.opera.browser'
desired_caps['androidDeviceSocket'] = desired_caps['appPackage'] + '.devtools'
So I was able to use the opera driver to automate tests on the opera browser on android, however, it was unable to provide the functionality needed to automate testing on the opera mini browser on android.

Appium: How to get current window?

I have Appium 1.4.13
IOSDriver<MobileElement> driver = new IOSDriver<MobileElement>(appiumUrl, desiredCapabilities);
How do I get current window (UIAWindow)? How do I get all elements on that window?
hi Artem appium tool only automates the app not android functionalities so you cant retrieve like home, settings window just like selenium does browser automation not the windows system (for that we use external tools like AutoIt and Sikuli), To retrieve app handles we use getcontextHandles() method to know we are in native app or Web view... hope this helps