Skip to content

Instantly share code, notes, and snippets.

@arlando
Created October 6, 2014 15:22
Show Gist options
  • Select an option

  • Save arlando/9ec1d684fcaed117c28a to your computer and use it in GitHub Desktop.

Select an option

Save arlando/9ec1d684fcaed117c28a to your computer and use it in GitHub Desktop.
attachData.java
@Given("^I perform a query$")
public static void I_perform_query() {
driver.navigate().to("https://qa.1stdibs.com");
driver.manage().timeouts().setScriptTimeout(5, TimeUnit.SECONDS);
Object response = js.executeAsyncScript(
"var callback = arguments[arguments.length - 1];" +
"var xhr = new XMLHttpRequest();" +
"xhr.open('GET', 'https://qa.1stdibs.com/soa/solr/1stdibs/select?q=category_search%3A1&rows=0&wt=json&indent=true&facet=true&facet.field=l3_facets&facet.limit=100000&fq=seller_pk:f_9534', true);" +
"xhr.onreadystatechange = function() {" +
" if (xhr.readyState == 4) {" +
" callback(xhr.responseText);" +
" }" +
"};" +
"xhr.send();");
try {
JSONObject json = new JSONObject((String) response);
System.out.println(json.toString());
} catch (JSONException e) {
throw new PendingException("JSON did not work: " + e.getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment