How to upload image using selenium webdriver (Mac) - selenium

Unable to Upload image using selenium web driver in MAC
HTML content having a button "choose Photo", on clicking it upload window will be opened.
AS code doesn't have an input type as file I couldn't use Send Keys .
I have tried the Robot class, but it has the constraint that we couldn't run in the background.
Kindly suggest the methods can be used on MAC .(Am able to successfully upload using AutoIT in windows)
Thanks
Kavitha S

Usually the choose Photo button will make us interact with the desktop, Selenium works on web-based applications. AutoIt can work well because it is intended for desktop applications.

I agree with #Frian answer that selenium web driver only works on the browser. However, from my understand I’m not sure if AutoIt is compatible with Mac you may have to use an alternative. You can find a list of alternatives here - alternativeto.net/software/autoit/?platform=mac

Related

Does Microsoft UI Automation Framework work with Chrome, Python and Java Apps?

I am working on an automation project, in which I need to capture the activities [ application launched, data entered, input type etc.] user performs on a desktop. I came across Microsoft UI Automation framework which so far works well for native windows based applications like MS Office, .NET apps etc. However I did not find any useful information / samples of capturing the information from different web browsers [Chrome is a must], Python apps, Java Apps etc. Can someone please confirm whether MS UI Automation Framework supports such apps. Any working example to extract user activities from these apps would be highly appreciated. Thanks.
Chrome only supports UI Automation for toolbars, tabs, menu, buttons around the web page. Everything that's rendered as a web page is not seen by UIA.
For the web page content, the easiest way is to use Selenium (driven by the ChromeDriver), which is kind of a de facto standard for browsers, and has nothing to do with UIA.
To test if an app supports UIA, and how far it does, it's very easy, just run UIA's Inspect tool and check the UI tree over that application.
Some additions to Simon's answer...
Chrome page content can be seen by UIA if you run chrome --force-renderer-accessibility. Only for existing Chrome process it won't work. Though user can create a new tab chrome://accessibility manually and enable UIA for all or some chosen pages. This method also works for AT-SPI accessibility technology on Linux. Of course, Selenium WebDriver is an industry standard here. But another way exists. Both Mozilla and IE support UIA by default.
Inspect.exe can be simply downloaded from this GitHub repo.
Regarding Java apps it depends on the app type. Your chances is about 50/50.
WxPython or PyQt5 are good for UIA. TkInter or Kivy apps are not.
P.S. There is an example how to drag a file from explorer.exe and drop to Google Drive in Chrome using Python library pywinauto.
I'm a bit late to the party..
But Chromes accessibility features are only activated once something tries to access it's accessibility.
If you call AccessibleObjectFromWindow ([DllImport("oleacc.dll")]) with the window handle an existing chrome window will have its accessibility activated (and you'll see the actual web page content in UIA!).
If the chrome window is opened after your app is running - Chrome pings open processes for any open accessibility apps... for that you use AccessibleObjectFromEvent and the event you're responding to comes from the windows pipeline: EVENT_SYSTEM_ALERT = 0x0002 .
The bottom line is - you have to tell chrome that there's something installed that wants to access it's web page content.
Oh! and your application has to be signed!! Unsigned apps won't be able to access web content - I think that's the same in firefox too.
I hope this helps someone in the future.
See:
https://www.chromium.org/developers/design-documents/accessibility

How can I access browser extension's popup using selenium?

I want to write an acceptance test for my browser extension. I've tried to initiate an extension via selenium but I can't seem to access a content of popup. Can someone suggest how can I do it with selenium or any other way to write UI/acceptance tests for browser extensions? Thanks.
How can I access browser extension's popup using selenium?
It's not possible. Selenium supports interaction with web view only.
What you can do with Selenium and extension for sure is automatic installation: https://stackoverflow.com/a/16512012/2517622
You may try to use desktop automation tools (e.g. White on Windows platform) for clicking on extension popup but it's not that easy and it's not platform independent as Selenium.
Here is the workaround we came up. Unless someone posts here the "right" solution I will consider this as the best approach.
So eventually, our extension is an iframe which just loads a page content from our website + does some other neat stuff. We simply open that url in a new tab and do regular selenium tests.
Side not: we have considered to write a little javascript wrapper to be able to access ext via main window through javascript. E.g. there is some js in ext that listens to main window's events and perform certain actions. Tho, it is too much efforts and doesn't really sound like a proper acceptance test so we discarded this approach.

Can't upload file from browser. RobotFramework, Selenium + Autoit on remote host

I have read many posts with similar problem but I didn't find any solution.
In my tests I'm uploading some files - after click on button in app in browser system shows window 32770 (opening or browse). I'm using AutoIt library for RobotFramework to handle upload action by this system window. Everything works perfectly until I run it on remote hosts (windows slave computer) and terminal's screen is covered.
Has anybody met and solved such an issue?
The most common way of uploading files with Selenium2Library is to use the Choose File keyword, which bypasses the need to interact with a popup dialog.
Please use this
choose file(locator,Path)
locator: Location of element where you click to upload image
Path: Path of image
Put your image is working directory.

Selenium Golang binding without server

There are many selenium webdriver binding package of Golang.
However, I don't want to control browser throught server.
How can I control browser with Golang and selenium without selenium server?
You can try github.com/fedesog/webdriver which says in its documentation:
This is a pure go library and doesn't require a running Selenium driver.
I would characterize the Selenium webdriver as a client rather than a server. Caveat: I have used the Selenium webdriver (Chrome version) from .Net and I am assuming it is similar for Go.
The way Selenium works is that you will launch an instance of it from within code, and it creates a live version of the selected browser (i.e. Chrome) and your program retains control over it. Then you write code to tell the browser to navigate to a page, inspect the response, and interact with the browser by filling out form data, clicking on buttons, etc. You can see what is happening on the browser as the code runs, so it is easy to troubleshoot when the interaction doesn't go as planned.
I have used Selenium to upload tens of thousands of records to a website that has no API and only a graphical user interface. Give it a chance.

Selenium - dialog box

When the browser launch is initiated by SeleniumRC, a dialog box always comes to ask for username/password to login to our proxy server (however, it is prepopulated with username/password, all has to be done is just press the OK button).
selenium.open("/");
selenium.type("q", "selenium rc");
selenium.click("btnG");
selenium.waitForPageToLoad("10000");
assertTrue(selenium.isTextPresent("Results * for selenium rc"));
// These are the real test steps
//selenium.stop();
After the first command, the dialog box appears and I want to dispose of that dialog box PROGRAMMATICALLY. Any help?
I don't think you'll be able to address this just by using Selenium, that modal dialog is outside the JavaScript boundaries in which selenium works.
The two alternatives I can think of are:
Using WebDriver (soon to be merged into selenium 2.0): has native support over the browser, which allows you to do that kind of stuff.
Using an OS level automation library just for clicking that prompt and you go back to selenium with the rest. The libs available for this things are language dependent, so you will find a lot of different options as Robot for java or pyWinAuto for python.
Update: New alternative:
You can use autoIT as a simple and fast solution under windows.