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();
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!!
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 wanted to get resource id and content description of android elements at runtime.
i tried this:
myElement.getAttribute("resource-id")
myElement.getAttribute("content-desc")
but getting error as "this element does not have the resource-id attribute".
Is there any way to get this ?
According to this post, the way to get "content-desc" is to use
myElement.getAttribute("name").
for resource-id use: webElement.getAttribute("resourceId")
To get content-desc use:
myElement.getAttribute("contentDescription")
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")
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();
}