i need help regarding html parser i want to get the first attribute"href" value of tag "a" please resolve my problem.I want to fetch this link from the code http://myneta.info/gujarat2012/candidate.php?candidate_id=1591,
i am attaching the snap please see and provide some solution,
i have tried this code but not works for me -
String temp = source.getElementById("main").getFirstElementByClass("grid_9").getAttributeValue("a");
here is image
Please try the following:
source.getElementById("main").getFirstElementByClass("grid_9").getFirstElement("a").getAttributeValue("href")
Related
I need to see the description of the JFoenix component JFXTextField.
This should usually be possible with CTRL + clicking on "JFXTextField" somewhere in the code.
In this video it works, see 3:20
https://www.youtube.com/watch?v=MU0MCdk3i7s.
However when I do this, this is what I get:
class description
I don't know what's the cause of this so can anybody tell me how I get access to this description?
Thank you!!
driver.findElementByXPath("//android.widget.TextView[#text='a1492']/../following-sibling::android.view.ViewGroup").click();
This does not work. Am I missing anything?
#text is looking for an attribute text. If you're actually after the text content, it's [text()='a1492'].
You can try below, this will solve your problem:
driver.findElementByXPath("//android.view.ViewGroup[preceding-sibling::android.view.ViewGroup/*[#text='a1492']]").click();
Please can someone point me to the right direction with below code?
driver.findElement(By.id("div#h4clock a.location").equals("London"));
I used getText("London") but it did not work.
I am quite new so any advise would be very much appreciated.
I also want to have a string to store the element London and display it using Println.
Many thanks in advance,
Hamid
The selector does not look like as an id that cssSelector. Try
driver.findElement(By.cssSelector("div#h4clock a.location")).getText().equals("London");
Edit:
WebElement city = driver.findElement(By.cssSelector("div#h4clock a.location"));
String getcity = city.getText();
System.out.println(getcity);
I am having a active page with its url like http://localhost:8085/projectName/namespace1/namespace2/namespace3/sell.action?id=22
Now i want get the action name(4th name after the sign /) i.e setuppageforwared.
How to achieve this ? Please help me to know because i read many books of struts2 i could not find anything which solve this problem.
Before i was using PHP framework codeigniter which easily solve this type of problem using uri segment features(click here) . I am aspecting the same here in Struts2.
Given Url String: http://localhost:8085/projectName/namespace1/namespace2/namespace3/sell.action?id=22
Expected Output: sell
Did you look for ActionContext#getName() ?
Edit :
Since you were not clear about it, I suppose you want to get the name of the action being executed from inside the action. So, in your action execute method, you'll have something like this :
String actionName = ActionContext.getContext().getName();
input.replace("&", "&").replace("<", "<").replace(">", ">").replace(""", "\"");
im using this line of code as a sudo htmlspecialchars converter. with my application, it doesnt need to be too elaborate.
for some reason the above code does not replace("&", "&"), it doesnt seem to do anything.
any advice?
input = input.replaceAll("[^\\x20-\\x7e]", "");
i also tried this.
In android there is one class Html inside android.text.Html which you can use like this as below:
Html.fromHtml(any_html_text);
But this function will return Spanned object so use
Spanned spn=Html.fromHtml(any_html_text);
You can set this spanned text to any button or textview text Hope it will help you.
See this link also for your reference.
Instead of doing this manually, check out the Html class. Calling Html.fromHtml() should do the trick.
Trying to escape/unescape html by replacing strings yourself you might introduce security issues in your application (depending on what it does with the output). Either use Html.FromHtml or from Apache libs org.apache.commons.lang.StringEscapeUtils.unescapeHtml
This does the work -
public String cleanString(String dirty) {
return Html.fromHtml(dirty).toString();
}