JSFiddle - React, Tailwind, and code Playground

by jestho

JavaScript

function selectCompanies(type) {
    var leadCompanies = ["Troll", "Eika", "Storebrand", "DNB", "Landbruksforsikring", "Tryg", "Frende", "If", "Nemi", "KLP", "Watercircles"],
        buyCompanies = ["Troll", "Eika", "Storebrand", "DNB", "Landbruksforsikring", "Tryg", "Frende", "If", "Nemi", "KLP", "Watercircles"],
        company1, company2, company3;
    
    Array.prototype.randomCompany = function() {
        return this[Math.floor(Math.random() * this.length)];
    };
    
    company1 = $('.firmLogo[alt=' + leadCompanies.randomCompany() + ']').parent('td').siblings('.compareCell.active:first');
    company2 = 'td.compareCell.pc.active[data-value]:nth(5)';
    company3 = 'td.compareCell.pc.active[data-value]:nth(10)';
    
    
    return penger.sleuth.createActions()
        .waitForElementExistence(company1, true, 10000).click(company1)
    ;
}