简体   繁体   中英

How to implement IF statement in Protractorjs Spec.js file?

I am trying to run spec.js file for multiple browsers ie, using Multicapabilities in conf.js .

But I want one statement of code to be executed only for IE and I am trying to put that in IF statement by taking the title of the browser as the condition in IF. But the if statement is not getting executed and throwing me error as:

object is not a function

Can someone help me how to write an IF statement in protractor?

You can use browser.getCapabilities() :

browser.driver.getCapabilities().then(function(caps) {
    var browserName = caps.caps_.browserName;

    if (browserName === "internet explorer") {
        // ...
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM