Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Link Parser doesn't follow <frame src="http://www.example.com/"> links #1672

Closed
asfimport opened this issue Feb 1, 2006 · 2 comments
Closed

Comments

@asfimport
Copy link
Collaborator

Matthew Buckett (Bug 38474):
HTML Link Parser doesn't find <frame> tags in a page. It only finds anchor and
form tags.

OS: Linux

@asfimport
Copy link
Collaborator Author

Matthew Buckett (migrated from Bugzilla):
Created attachment anchormodifier.txt: Adds support for following frame tags to AnchorModifier.java

anchormodifier.txt
Index: /home/buckett/workspace/jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java
===================================================================
--- /home/buckett/workspace/jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java	(revision 372904)
+++ /home/buckett/workspace/jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java	(working copy)
@@ -99,6 +99,7 @@
 		}
 		addAnchorUrls(html, result, sampler, potentialLinks);
 		addFormUrls(html, result, sampler, potentialLinks);
+		addFramesetUrls(html, result, sampler, potentialLinks);
 		if (potentialLinks.size() > 0) {
 			HTTPSamplerBase url = (HTTPSamplerBase) potentialLinks.get(rand.nextInt(potentialLinks.size()));
 			sampler.setDomain(url.getDomain());
@@ -196,6 +197,39 @@
 			}
 		}
 	}
+    
+    private void addFramesetUrls(Document html, HTTPSampleResult result,
+			HTTPSamplerBase config, List potentialLinks) {
+		String base = "";
+		NodeList baseList = html.getElementsByTagName("base");
+		if (baseList.getLength() > 0) {
+			base = baseList.item(0).getAttributes().getNamedItem("href")
+					.getNodeValue();
+		}
+		NodeList nodeList = html.getElementsByTagName("frame");
+		for (int i = 0; i < nodeList.getLength(); i++) {
+			Node tempNode = nodeList.item(i);
+			NamedNodeMap nnm = tempNode.getAttributes();
+			Node namedItem = nnm.getNamedItem("src");
+			if (namedItem == null) {
+				continue;
+			}
+			String hrefStr = namedItem.getNodeValue();
+			try {
+				HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(
+						hrefStr, new URL(result.getURL(), base));
+				newUrl.setMethod(HTTPSamplerBase.GET);
+				log.debug("possible match: " + newUrl);
+				if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
+					log.debug("Is a match! " + newUrl);
+					potentialLinks.add(newUrl);
+				}
+			} catch (MalformedURLException e) {
+			} catch (org.apache.oro.text.regex.MalformedPatternException e) {
+				log.error("Bad pattern", e);
+			}
+		}
+	}
 
 	public static class Test extends JMeterTestCase {
 		public Test(String name) {

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Thanks for the patch; it has been applied to the 2.1 branch and will appear in
the next release of JMeter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant