I have an HTML that includes 2 paragraphs:
<p style="text-align: center">centered text example</p>
<p style="text-align: right">alignment right text example</p>
I added it in my android TextView using Html.fromHtml
As a result in my view first paragraph aligned center(as expected), but second paragraph doesn't aligned rigth and aligned to left.
How is it correct to set html alignment properties to make work it in android?
That is because for some reason Html.fromHtml supports start, center and end as text-align values. It does not match CSS, but that's how it works.
Proof
change
"text-align: right"
to
"text-align: end"
in your inline css
Try using
"text-align: end"
instead of
"text-align: right"
Related
I want to get the text inside the element that comes after a certain text ie. 'Projected earning growth'. I want to get the value 18.10% . The pattern I want to follow is lookup for a certain text as above, and then get the text following the immediate h2 element.
Is it possible to have one xpath expression that will do both the steps together?
Match the div for a certain text 'Projected earning growth'
Go to the immediate h1 element outside the div (I have to jump two divs here to get to the h1 element)
How do I match for a text and get to the next immediate h1 element via xpath?
<div>
<div class="p small mb-8 box-label text-left text-blue-500">
<div class="tt-container">
<button aria-label="open tooltip" class="button link" type="button" role="tooltip" aria-expanded="false">
Projected earning growth
</button>
</div>
</div>
<h2 class="mb-8 text-left">18.10%</h2>
</div>
If I understood you correctly, you want to go from Projected earning growth to 18.10% which is in h2 tag. Not sure why you've mentioned h1 tag though.
//button[contains(text(),'Projected earning growth')]/../../following-sibling::h2
should get the job done,
Note that /.. to go to go level up in HTMLDOM.
This is straight up solution to the problem that you are having.
I would also suggest you to have a look on xpath parent and ancestor.
I have a radio choice form which is generated with the RadioChoice component in wicket. Here <span/> covers all of the possible choices in the form. I want the span to go downwards. One option per row on screen, but I am currently stuck with the problem that if i try to style choice it get styled as one. For example, if i try to take border: 1px solid red; it creates only one border, and not one for each choice.
<form class="mapSelector" wicket:id="radioForm">
<span class="choice" wicket:id="radio"></span>
</form>
I am not sure I understand what you mean with I want the span to go downwards. One option per row on screen but it sounds like you need a <div> instead of <span>, i.e. an element with display:block.
I am not sure how CSS border is related to downwards and row.
I'd suggest you to see what is the generated HTML because this Wicket Component may generate <label> too for each radio element.
How can I click on a button based on the text "See More" or "Sign Up"
<div data-reactid=".0.0.$LandingPage.0.1.0.0.1.0.3">
<button class="arda-button btn -primary" data-reactid=".0.0.$LandingPage.0.1.0.0.1.0.3.$main-menu-see-more">See More</button>
<button class="arda-button btn -primary" data-reactid=".0.0.$LandingPage.0.1.0.0.1.0.3.$main-menu-sign-up">Sign Up</button>
</div>
</div>
Or based on the html above can you see a unique way of identifying and clicking on the two buttons?
Thanks
Identify using contains text() as 'see more' and 'sign up', should work.
By.xpath("//button[contains(text(),'See More')]")
By.xpath("//button[contains(text(),'Sign Up')]")
You can use XPATH ( Consider the Xpath is not big and Ugly) where each button will be separate.
If XPATH is ugly and long use regular Expression where data-reactid CONTAINS "main-menu-see-more" for "See More" button. And data-reactid CONTAINS main-menu-sign-up for Sign up button
"//*[contains(#data-reactid,'main-menu-see-more')]"
" //*[contains(#data-reactid,'main-menu-sign-up')]"
What about linked Text "See More" and "Sign Up".
Please share your feedback its working not......
I avoid XPath like the plague unless absolutely necessary because it's complicated, slower than other methods, and more prone to breaking (in general). I would do this using a CSS Selector.
The data-reactid is unique for each of these elements so I would use those to find the desired elements instead of the text.
driver.findElement(By.cssSelector("button[data-reactid='.0.0.$LandingPage.0.1.0.0.1.0.3.$main-menu-see-more']")).click();
This code finds a button that has the specified data-reactid and clicks it.
CSS Selectors are very powerful and it lets you avoid XPath... which is a good thing. :)
CSS Selector reference
I'm having a paragraph system (parsys) in my page, and inside that I'm dragging one component; that component has two paragraph systems inside it. So now I will be dragging a rich text component in both of the two paragraph systems which are present in the component. However, after dragging the rich-text components in the two paragraph systems, I'm not able to edit the those two rich text components, as they got overlapped. Can you tell me whether we can have a parsys inside a parsys and will that support content authoring.
Yes it is possible to have a parsys inside a parsys. The overlapping problem would be a CSS issue, and can be solved most of the time by adding the following div at the end of your component code.
<div style="clear:both"></div>
Also, to prevent adding additional div styles to your page, this should be done only in author mode:
<% if (WCMMode.fromRequest(request) == WCMMode.EDIT) { %>
<div style="clear:both"></div>
<% } %>
I have this div
<div ui:field="myText" class="{style.myText}"> </div>
Node x = divText.getChild(selectText.getSelectedIndex()-1).getFirstChild();
In node x i am getting the exact text i am looking for, but now i want to make some changes with that text, like change the color of that text only,
I do not want to change the color of my div, i want to change the color of some specific Node in my div
is there some way i can achive this.
Thanks