working on it ...

Filters

Explore Public Snippets

Sort by

Found 1.6M snippets

    public by pleabargain modified 8 hours ago  9  2  3  0

    javascript output to console current full date as text

    // Enter here the actual content of the snippet.
    // Array of day names
    let dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
    				"Thursday","Friday","Saturday");
    
    // Array of month Names
    let monthNames = new Array(
    "January","February","March","April","May","June","July",
    "August","September","October","November","December");
    
    let now = new Date();
    console.log(dayNames[now.getDay()] + ", " +
    monthNames[now.getMonth()] +
    " " + now.getDate() +
    ", " + now.getFullYear());
    //output ~ Sunday, February 19, 2017
    

    public by hamidmousavi modified 20 hours ago  9  0  2  0

    universal wrapper to make sure an element is visible

     public static boolean isElementPresentAndDisplayed(RemoteWebDriver driver, final WebElement element) {
            try {
                return element.isDisplayed();
            } catch (NoSuchElementException e) {
                return false;
            }
        }
    
    ....
    
      Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
                        .withTimeout(timeoutSeconds, TimeUnit.SECONDS)
                        .pollingEvery(1, TimeUnit.SECONDS)
                        .ignoring(NoSuchElementException.class)
                        .ignoring(StaleElementReferenceException.class)
                        .ignoring(InvalidElementStateException.class);
                try {
                    return wait.until(drv -> {
                        final List<WebElement> foundElements = drv.findElements(by);
                        if (foundElements.size() > 0) {
                            for (WebElement element : foundElements) {
                                if (isElementPresentAndDisplayed(driver, element)) {
                                    return true;
                                }
                            }
                        }
                        return false;
                    });
                } catch (TimeoutException e) {
                    return false;
                }

    public by hamidmousavi modified 20 hours ago  11  0  2  0

    Selenium TryFindElement

    public void Test()
    {
        IWebDriver driver = new FirefoxDriver();
        IWebElement element = null;
        if (TryFindElement(By.CssSelector("div.logintextbox"), out element)
        {
            bool visible = IsElementVisible(element);
            if  (visible)
            {
                // do something
            }
        }
    }
    
    public bool TryFindElement(By by, out IWebElement element)
    {
        try
        {
            element = driver.FindElement(by);
        }
        catch (NoSuchElementException ex)
        {
            return false;
        }
        return true;
    }
    
    public bool IsElementVisible(IWebElement element)
    {
        return element.Displayed && element.Enabled;
    }

    public by hamidmousavi modified 20 hours ago  8  0  3  0

    This method will return WebElement After Given wait

    // This method will return WebElement After Given wait           
    public static WebElement FindWithWait(WebDriver driver,By locator, int seconds) throws Exception{
    		// Sleep until the Element we want is visible or n seconds is over
    		WebElement element=null;
    		
    		//Because if implict wait is set then fluint wait will not work
    		driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
    		try{
    					FluentWait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver)
    							.withTimeout(seconds, TimeUnit.SECONDS)
    							.pollingEvery(200, TimeUnit.MILLISECONDS)
    							.ignoring(NoSuchElementException.class)
    							.ignoring(StaleElementReferenceException.class)
    							.ignoring(WebDriverException.class);
    									 
    				element=fluentWait.until(
    							
    							ExpectedConditions.visibilityOfElementLocated(locator)
    							
    							);
    				return element;
    					
    		} catch(Exception e){
    			
    			throw new Exception("Timeout reached when searching for element! Time: " + seconds+" seconds " +"\n" +e.getMessage());
    			
    		}
    		finally {
    			driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    		}
    		
    	}

    public by pleabargain modified yesterday at 3:46:06 PM  7  0  3  0

    add all function arguments together

    function sum(){
    	let result =0;
    	//loop through all of the values in func args
      for (i =0; i < arguments.length;i++){
        //now add them toghether
    		result += arguments[i];	
    	
    	}
    	return result;
    }
    sum(34,34,236,32);

    public by JavierSalazar modified Thursday at 6:26:40 PM  19  1  1  1

    Calculo de Numero base dado un total y un procentaje

    Formula para el calculo de Numero base dado un total y un procentaje. Ejemplo: Si tenemos un monto TOTAL ya con IVA sumado. Si conocemos el porcentaje del IVA podemos obtener un numero base que al aplicarle el porcentaje de IVA y sumarselo, obtenemos el TOTAL
    function calcularMontoBase (Montofinal,iva) {
    var montoBase =0;
    
    montoBase = (Montofinal/((iva/100) + 1));
    return montoBase;
    
    }                        

    public by VladimirMijatovic modified Thursday at 12:24:26 PM  13  1  1  0

    DIV

    <div></div>

    public by maholtz modified Wednesday at 2:12:16 PM  12  0  3  0

    Wert einer Zelle relativ zur aktuellen Zelle

    Mit der folgenden Formel kann in Google Tabellen ein Wert aus einer anderen Zelle verwendet werden, die um X-Zeilen und Y-Spalten von der aktuellen Zelle versetzt sind.
    // ROW() Gibt die aktuelle Zeile zurück
    // COLUMN() die aktuelle Spalte zurück, allerdings als Zahl, nicht als Buchstaben
    //
    // Der Wert der gewünschten Zelle, die also eine bestimmte Anzahl
    // an Zeilen und Spalten versetzt ist, kann entsprechend mit 
    // ROW()-2 und COLUMN()-4 gewählt werden
    // 
    // via concatenate wird ein Sting in der Form "R41C4" erzeugt,
    // die Schreibweise kann dann an die Funktion indirect übergeben 
    // werden (Parameter FALSE!) und gibt dann den Wert aus.
    //
    // Der Wert kann dann weiter verarbeitet werden.
    indirect(concatenate("R";ROW()-2;"C";COLUMN()-4);FALSE)

    public by JavierSalazar modified Tuesday at 7:31:39 PM  18  3  2  0

    Pasar varios datos con ajax (Metodo POST)

    Pasar varios datos con ajax (Metodo POST)y es recibido por archivo php con la variable $_POST
    $.ajax(
    {
            url: "<?=resApi;?>procesarProducto.php",
            type: "post",
            dataType: "html",
            data: ({accion: "transferir",subaccion: "buscarStockSucursal", codigoprod: producto, sucursal: sucursal}),
            cache: false,
    })
        .done(function(res)
        {alert(res);}  

    public by wojtekmalczewski modified Feb 9, 2017  12  0  2  0

    RegEx

    (?i) (\d\d) 
     $1&nbsp;
     
    (?i) (\d)(\d) 
    $1&nbsp;
    
    (?i)(\ [aiouwz]|\ (co)|\ (do)|\ (na)|\ (od)|\ (ze)|\ (to)|\ (tu)|\ (ta)|\ (że)|
    \ (li)|\ (iż)|\ (tę)|\ (tą)|\ (po)|\ (bo)|\ (ob)|\ (on)|\ (są)|\ (aż)|\ (te)) 
    $1&nbsp;
    • Public Snippets
    • Channels Snippets