2gis / Winium.StoreApps.CodedUi

Prototype of Winium.StoreApps driver using CodedUI. Implements JsonWireProtocol for automation of Windows Phone applications
10 stars 8 forks source link

Test a website in mobile browser #25

Open sunit82 opened 8 years ago

sunit82 commented 8 years ago

I want to test a website in windows browser (IE or any other installed browser) in emulator or device. So for this I wan't to know how to start the IE which is installed by default in windows emulator or device. Through winium we are always asked to provide "app" capability which is mandatory to start Remote driver. But since we are trying to start the inbuild browser we don't have a appx\appxbundle file path to provide as "app" capability. Can anyone share a sample code for the same pls. Thanx.

NickAb commented 8 years ago

If you want to test website in Windows Phone browser, then I would suggest you to use https://github.com/forcedotcom/windowsphonedriver which is a Selenium driver for Windows Phone. It uses an app with WebView in it, that acts just like standard browser on Windows Phone. All or almost all features of selenium will work as expected.

If you would like to stick to CodedUI, note that a limited subset of commands is implemented yet, searching by css selectors or xpath will not work, some elements might not have id or class as the Winium does not interact with WebView directly and does not distinguish web elements from native elements, all of this is done by Microsoft Automation libs which have their own logic on how to map web elements to Automation elements.

Actually you can skip app capability, to do so, do not specify it at all, or set it to null or empty string. You would be able to open preinstalled apps using something like (in python) self.driver.switch_to.window(TILE_ID). If I remember correctly TILE_ID can be obtained from result of executing page_source command while start screen is open on the emulator or device. TILE_ID is automation id attribute of corresponding tile. See samples for example on how to run automation script against preinstalled calculator https://github.com/2gis/Winium.StoreApps.CodedUi/blob/master/TestExamples/test_sample.py#L92