How to load complete Html page as response

Hi team,

I have scenario like I am making a request and i am getting response as Html page (Not json) with this response can i load that page as next screen to continue the rest development

Thanks in advance

Why don’t you load it like a normal html page using the regular concept loadPage and similar?

This might work… it assumes that we have a current window. Not sure if there is any yet… no chance to try it out.

HtmlPage page = HTMLParser.parseHtml(response3, this.getWebClient().getCurrentWindow());
this.getWebClient().getCurrentWindow().setEnclosedPage(page);

response3 is your WebResponse. I have not tried it so no warranties.

Suggestion: How about an XLT support contract to help you quicker and more direct? This forum is voluntary support and might or might not be able to help you. In addition, a support contract is covered by an NDA so code sharing is easier.

Hi @rschwietzke Thanks for the replay ,
While implementing this i could not find any method related to HTMLParser just i found an interface with a method “parseHtml” and this method not implemented in any other classes to use

Sorry: HtmlUnitNekoHtmlParser htmlParser = new HtmlUnitNekoHtmlParser(); used an older version to fiddle the code together.

It is taking 3 parameters and i just want to know what need to send for Html page and it is not returning anything

You got the first two already and the last is up to your discretion. Likely false.

image

if i use like this it is throwing null pointer exception and its not able to load Html page

Based on Html page i need to find some elements and get the authorization token and make another request.

You don’t have an HtmlPage yet I guess, hence this is null. Is there a way to share the test suite or at least the parts needed to reproduce it? I cannot fix code problems by screenshot.

I have sent you mail at support@xceptance.com
Please go through it and you will find my issue

Any update please let me know

Thanks

1 Like

CheckoutPayment has been changed to fireFrom. You already load a full page with loadPagebyClick early on.

Please note that your req1 returns an html page with indicates and shipping error

@Override
protected void doExecute() throws Exception
{
	// Fill payment form
	String url=ShippingAddressPage.shippingAddressForm.GetContinueUrl();
	loadPageByUrlClick(url+"?previous_step=shipping_method&step=payment_method");
	String Csrf=PaymentPage.paymentForm.GetCsrf();
	
	// Click continue button
	//loadPageByClick(PaymentPage.paymentForm.getContinueButton());
	final List<NameValuePair> Paymentparms = new ArrayList<NameValuePair>();
	Paymentparms.add(new NameValuePair("_method", "patch"));
	Paymentparms.add(new NameValuePair("authenticity_token", Csrf));
	Paymentparms.add(new NameValuePair("previous_step", "payment_method"));
	Paymentparms.add(new NameValuePair("checkout[payment_gateway]", "78134345951"));
	Paymentparms.add(new NameValuePair("complete", "1"));
	Paymentparms.add(new NameValuePair("checkout[total_price]", PaymentPage.paymentForm.gettotalPrice()));
	Paymentparms.add(new NameValuePair("checkout[total_price]", account.shippingAddress.city));

	// this produces Error - Shipping - MulesoftPOC - Checkout !!!!!!!!!!!!!!!
	HttpRequest req1 = new HttpRequest()
			.XHR()
			.url(url)
			.POST()             
			.postParams(Paymentparms);
	WebResponse response1=req1.fireFrom(getHtmlPage());

	HttpRequest req2 = new HttpRequest()
			.XHR()
			.url(url+"/thank_you")
			.GET();      
	WebResponse response2=req2.fireFrom(getHtmlPage());

	Assert.assertEquals("Test responce", response2.getContentAsString());
}

Today while running the script using JUnit i am getting this warning message

Ignore for now. Which JDK do you use?

I am using JDK 11.0.14

Which XLT? Did this just start today?

Now i am using XLT 6.0.0

There is a migration to the latest version open that hopefully will address this as well: https://github.com/Xceptance/XLT/issues/24