Search code examples
javascriptprotractorappiumscreen-resolutionangularjs-e2e

Protractor - Appium -


I am able to run automated tests both on Desktop, Mobile devices using Protractor + Appium. However having issues to run custom test, that work only in Desktop/Mobile only.

for eg: One of my test validates Breadcrumbs, which are displayed only in Desktop screen resolution.

Would you please advise, if there is a solution to check if test is being executed in Desktop or Mobile.

eg; it('check breadcrumb in website', function(){
       if(isDesktop()){
         contentItemPage.checkBreadCrumb();  
       }
    });

Similar to the following, to check if browser is Chrome or not.

 function isChromeBrowser(){ 
          browser.getProcessedConfig().then(function(config) {
               if(config.capabilities.browserName.valueOf() === new String('chrome').valueOf()){
                    return true;
               } 

               return false;
              
              
       
          });
} 

Thanks in advance.


Solution

  • would you be able to use the appium capabilities and check the platformName?

    function isMobileBrowser(){
              browser.getProcessedConfig().then(function(config) {
                   if(config.capabilities.platformName.valueOf() === new String('Android').valueOf() || new String('iOS').valueOf()){
                        return true;
                   }
    
                   return false;
    
              });
    }