View getPrivateProperty.php
private function getProtectedProperty($class, $propertyName)
{
$reflectObj = new \ReflectionObject($class);
$extensions = $reflectObj->getProperty($propertyName);
$extensions->setAccessible(true);
return $extensions->getValue($class);
}
View setPrivateProperty.php
private function setProtectedProperty($class, $propertyName, $setValue)
{
$reflectObj = new \ReflectionObject($class);
$extensions = $reflectObj->getProperty($propertyName);
$extensions->setAccessible(true);
$extensions->setValue($class, $setValue);
}
View runProtectedMethod.php
protected function runProtectedFunction($class, $methodName, $args = null)
{
$reflectMethod = new \ReflectionMethod($class,$methodName);
$reflectMethod->setAccessible(true);
if ($args == null)
{
return $reflectMethod->invoke($class);
} else
{
return $reflectMethod->invokeArgs($class, $args);
View RandomInt.java
/**
* Random generator in range
*
* @param minimum Number
* @param maximum Number
* @return randomNumber
*/
public int randomGenerator(int minimum, int maximum) {
Random rn = new Random();
int range = maximum - minimum + 1;
View IgnorePhpUnitTest.php
$this->markTestSkipped('This test is scipped ');
View ProxySelector.java
import java.net.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.IOException;
/**
* this class is needed for Java to connect to SOCKS proxy server
* Unfortunately Java cannot resolve remote DNS and therefore, when we set System.properties
* with our proxy server details, we hit incorrect server . This is because
* Java is connecting to Proxy, but DNS is resolving with system details and therefore goes to server directly.
View DbConnection.java
package Base.db_connection;
import org.json.JSONObject;
import java.sql.*;
import static Base.TestPropertiesLoader.getDbConnectionDetails;
public class DbConnection {
public Connection con = null;
View yaml_to_json_convertor.py
import yaml
import json
yml = "file_path"
data = yaml.load(open(yml,'r'))
json = json.dumps(data)
print(json)
View getJSONFromFile.java
public static JSONObject getJSONFromFile(String path) throws JSONException, IOException, ParseException {
JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader(path));
return new JSONObject(obj.toString());
}
View webDriverSnippets.java
public void refreshPage(){
driver.navigate().refresh();
}