w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Selenium and xpath: finding a div with a class/id and verifying text inside
To verify this:- <div class="Caption"> Model saved </div> Write this - //div[contains(@class, 'Caption') and text()='Model saved'] And to verify this:- <div id="alertLabel" class="gwt-HTML sfnStandardLeftMargin sfnStandardRightMargin sfnStandardTopMargin"> Save to server successful </div> Write this - //div[@id='alertLabel' and text()='Save to server successful']

Categories : Java

While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

Hidden XPATH to find element of text? Ruby-selenium
all your xpaths seems correct to me... I think when you are trying to find the element using your xpath ... the element is not loaded properly... try to use explicit wait. Please try to use the code provided below: wait = Selenium::WebDriver::Wait.new(:timeout => 10) wait.until { driver.find_elements(:xpath, "Any of your above mentioned xpaths") }

Categories : Ruby

Find an element by text and get xpath - selenium webdriver junit
The XPath of an element is not a definitive value. An element can be found by many XPaths. You cannot use Webdriver to extract an XPath and even if you could, it is unlikely to be the most efficient or sensible one, that can only be defined by the automator.

Categories : Selenium

Finding specific div element just below span with title text in cucumber
You want to do: title = "Title 2" within( find(:xpath, "//span[normalize-space(text())='#{title}']/following-sibling::div[1]") ) do click_link 'publish' end An explanation of the xpath: //span[normalize-space(text())='#{title}'] looks for the span with the title. Note that normalize-space(text()) is used to make handling of spaces easier by removing extra spaces. This allows specifying the title as "Title 2" instead of having to do " Title 2 " (ie having to specify the leading/trailing space). /following-sibling::div[1] says that from the span found, find the first div element that follows.

Categories : CSS

selenium - how to click on a link based on its text using css instead of xpath and without using the contains operator?
CSS selectors do not support node selection based on their text content. Actually there was a suggestion for a pseudo class :contains which would suit your needs, but it was removed from CSS 3 spec.

Categories : CSS

How to get text from span->li->ul-> Element
Try this: $(".cart-item").each(function(){ var shortId = $(this).find(".bold-14").parent("li").siblings("li").children("span").html(); var shortItem = shortId.replace(' ','').split(":"); var defaultCat = $(this).find(".spanDefCat").html(); var item = defaultCat.replace(' ','').split(":"); if(item[1]==0){ var id = parseInt(shortItem[1]); //do something }else{ var id = parseInt(shortItem[1]); //do something else } console.log(defaultCat); console.log(shortId); }); Note: Above code give you the DefaultCat:334 and ShortId:1010 so now you can use both in if else statement. If the format of DefaultCat:334 is same for all cart item then you can check whether it is 0 or not JSFIDDLE DEMO

Categories : Javascript

Getting text value without any nested element within span tag in JavaScript
document.getElementsByTagName("span")[0].firstChild.nodeValue="New text"; or document.getElementsByTagName("span")[0].childNodes[0].nodeValue="New text"; Using the Selectors API: document.querySelector("span").firstChild.nodeValue = "New Text"; JSFiddle

Categories : Javascript

Xpath: extract value from element using text outside of element
You want to locate the text node of interest first, rather than the div. From there, you can go to the preceding-sibling as you have tried. Try: //text()[normalize-space() = "Mobile"]/preceding-sibling::input/@name

Categories : HTML

Finding the searched text in google search result with selenium webdriver in Chrome
You're using terrible xpath. Try something like //input[@id='gbqfq'] When you're searching something by text, it is registry sensitive For your case with 5 results, you can use the following (I'm not familiar with C#, so here's the python code, you should understand it): first_five = driver.find_elements_by_xpath(".//*[@id='rso']//div//h3/a")[:5] #returns the list of first five result links for result in first_five: assert "selenium webriver" in result.text.lower(), "Result does not contain 'selenium webdriver'" # lower - to get rid off registry troubles

Categories : C#

Can this coDrops link effect work on text in element?
You have an extra comma in your css .highlight:hover::before, .highlight:focus::before,{ max-width: 100%; } should be .highlight:hover::before, .highlight:focus::before{ max-width: 100%; } .highlight:focus could be removed, since a span can't have focus. http://cdpn.io/uEiKf

Categories : CSS

Changing text of a span moves parent element left
This is sbecause you are floating the div to the left. remove the float, it is not needed as you have already declared inline-block DEMO http://jsfiddle.net/kevinPHPkevin/Sj3Gj/5/ div{ background-image: url('http://placekitten.com/200/300'); height: 16px; width: 16px; display: inline-block; }

Categories : HTML

CSS property "text-indent" not working with html span element
text-indent doesn't work on inline elements. <span> defaults to being inline. You need to change it so it works as an inline block: display:inline-block;

Categories : HTML

vertical alignment of text in span - text outside span
Something like this maybe? span { display: inline-block; line-height:1.25; vertical-align:middle; width: 135px; color: black; text-align: center; font-weight: bold; font-size: 15px; } a { background-color: rgba(216, 25, 11, 0.75); height: 70px; line-height: 70px; font-size:0; overflow:hidden; } li, a { width: 135px; display: inline-block; vertical-align:top; } span { -webkit-animation: slidein 2s ; /* Safari 4+ */ -moz-animation: slidein 2s ; /* Fx 5+ */ -o-animation: slidein 2s ; /* Opera 12+ */ animation: slidein 2s ; /* IE 10+ */ } @-webkit-keyframes slidein { 0% { margin-top: 70px; } 100% { margin-top: 0; } } @-moz-keyframes slidein { 0% { margin-top: 70px; } 100% { margin-top: 0; }

Categories : HTML

XPath: Find HTML element by *plain* text
You can use //*[contains(., 'This can not be found')]. The context node . will be converted to its string representation before comparison to 'This can not be found'. Be careful though since you are using //*, so it will match ALL englobing elements that contain this string. In your example case, it will match: <someOtherElement> and <body> and <html>! You could restrict this by targeting specific element tags or specific section in your document (a <table> or <div> with a known id or class) Edit for the OP's question in comment on how to find the most nested elements matching the text condition: The accepted answer here suggests //*[count(ancestor::*) = max(//*/count(ancestor::*))] to select the most nested element. I think it's only XPath 2.0. Wh

Categories : Python

How can I find the xpath of an element located by link text?
You could use - //div[contains(., 'Company Inc.')] or //div[contains(text(),'Company Inc.')] or //div[text()='Company Inc.']

Categories : Python

XPath: Find HTML element by plain text
You can use //*[contains(., 'This can not be found')] [not(.//*[contains(., 'This can not be found')])] This XPath consists of two parts: //*[contains(., 'This can not be found')]: The operator . converts the context node to its string representation. This part therefore selects all nodes that contain 'This can not be found' in their string representation. In the above example, this is <someOtherElement>, <yetAnotherElement> and: <body> and <html>. [not(.//*[contains(., 'This can not be found')])]: This removes nodes with a child element that still contains the plain text 'This can not be found'. It removes the unwanted nodes <body> and <html> in the above example. You can try these XPaths out here.

Categories : HTML

Get text of css element selenium
If you go to http://viewer.opencalais.com/ and type something like "There was a man named Bob Bob" and hit submit, then you see under the entity person the name Bob Bob. I'm trying to get that name "Bob Bob" basically. From the getText() docs: Get the visible (i.e. not hidden by CSS) innerText of this element But the text is initially hidden. You must first expand the Person element to make it visible. In this particular "Bob Bob" case, you can use: driver.findElement(By.id("toggleVisibilityImage1")).click(); But always make sure you're clicking the right expander. To make it more general, this selects the expander next to the "Person" category: //input[@class='collapseExpandIcon' and (../text()='Person')] and explanation: SELECT AN <input> ELEMENT //input[

Categories : Java

Selenium - how to get element and its subelements text
How I do this, 1. I open Selenium IDE, 2. select the text from the site that I want to get 3. Right click and use the available commands 4. Let say we use verify text. 5. Stop recording and convert the recording to webdriver . You get your code. It's simple, worked always for me. you can try (new WebDriverWait(driver, 60)).until(ExpectedConditions .textToBePresentInElement(By.id("Element ID"), "Text to verify"));

Categories : Java

Selenium - Get and compare specified length of text from web element
The basic premise is that if the string under test ends with dots, you check that the expected string starts with the string under test (but without the dots). Code below isn't tested and you might want to think about null string scenarios. static final String DOTS = "..."; String actual = "The quick brown fox..."; String expected = "The quick brown fox jumps over the lazy dog"; public void testStringWithDots(String actual, String expected) { if (actual.endsWith(DOTS)) { String prefix = actual.substring(0, actual.length() - DOTS.length()); Assert.assertTrue("Strings are same up to dots", expected.startsWith(prefix); } else { Assert.assertEquals("Strings are same", expected, actual); } }

Categories : Java

Duplicate span text into a text field in a form
You could always do the following function calculateSum() { var sum=0; $(":text").each(function() { if(!isNaN(this.value) && this.value.length!=0 { sum+=parseFloat(this.value); } }); $("#sum").html(sum.toFixed(0)); $("#myTextField").val(sum.toFixed(0)); //adding to text field }

Categories : Javascript

Selenium can't find element by xpath
Try as CSS Selectors : By by = By.css('div[id^="highcharts"] g[class^="highcharts"] > g > rec') g.class_name I used,as that <g> tags class name is not visible. Replace that class name with the proper class name.

Categories : Java

How to im-plement $("
Somw text
") in native javascript?
Create container div, then put string to innerHTML, then return firstChild of container div. function getDomFromHtml (htmlStr){ var container = document.createElement("div"); container.innerHTML = htmlStr; return container.firstChild; } fiddle: http://jsfiddle.net/NzHRc/

Categories : Javascript

unable to click on span element with .NET WebDriver but able with Selenium IDE
As Arran suggested: the problem was that the clicking occurred before the page got fully loaded (WebDriver problem) while with selenium IDE i had the application opened and loaded already so there was what to click already. so this is my stupidity) then the solution i've found is this: http://stackoverflow.com/a/16283166/1922804 i had a 'loading...' progress bar that i needed to disappear before proceeding with test execution.

Categories : C#

How can I vertically center the text in a span that is next to a span whose contents are taller?
Try to set a class identifier on your li element, then modify it via css using that identifier, for example: <li class="footer"> <!-- footer code goes here --> </li> And on css: li .footer{ /* Set margin here */ } Also, you can put your footer outside of the list and do the same thing, in order to avoid maybe css applied to it as part of the list and have a more simple css accessing.

Categories : HTML

Selenium does not find element via xpath using Chromedriver
First, make sure it it not in any kind of frames. Otherwise you need switch into the frame first, like this. Then try use css selector instead of XPath. For example (you may need try different variations): WebElement box = driver.findElement(By.cssSelector("td[onclick*="self.jssDetails.location='products.php?xUser=kery&amp;xRand=123';"]")); Also, you might want to post every XPaths you have tried, to help us analyse.

Categories : Java

How do i select text from a text field using 'CTRL A ' using selenium webdriver?
Humm.. Look Selenium::WebDriver::Element#text So use : elem = wait.until { element = driver.find_element(:id, 'embed-showembedcode') element if element.displayed? } puts elem.text # => target text will be printed here Now to fix the error,I would suggest you always do some machine representation test as below. It is not needed that Selenium::WebDriver::Keys mentioned mapping will be good to work in your machine: require "selenium-webdriver" puts Selenium::WebDriver::Keys::KEYS # => {:null=>"uE000", :cancel=>"uE001", :help=>"uE002", :backspace=>"uE003", :tab=>"uE004", # :clear=>"uE005", :return=>"uE006",:enter=>"uE007", :shift=>"uE008", # :left_shift=>"uE008", :control=>"uE009",.. } elem = wait.until { element = driver.find_element(:id, 'embed-

Categories : Ruby

XPath getting text from all elements that match XPath query
This works for xpath 2.0: string-join(/*/text(), ' ') Tested here, prints: Hello World !!! This is cool

Categories : PHP

Reading a text file of student names and text scores and finding an average
Oops: int i =Integer.parseInt ("TS"); This doesn't make sense. What number is "TS" supposed to represent? Edit: you state: I know that TS is not a valid number that's why I was trying to cast it to a number You can't "cast" letters to a number, again it makes no sense. You need to read in the Strings in the file and then parse those Strings, not some letters you make up. What your code should do is: read in each line in the file in a for loop inside this loop, split the String using String's split(" ") method. Use Integer.parse(...) to parse the 3rd item in the array returned. So would I use Integer.parse(String [] TS)? No, this won't even compile since you're trying to pass a String array into a method that takes a String parameter.

Categories : Java

Selenium not finding element
You're searching for ctl00_Header1_liAppointmentDiary, but there only is Header1_liAppointmentDiary, those are not the same... ctl00_Header1_liAppointmentDiary != Header1_liAppointmentDiary

Categories : Java

How to add some text after the text in the span using jquery?
var span = $('li span'); span.html(span.html() + '&times'); Is this what you're looking for? If you want to do it in one line: $(that).find('span')[0].innerHTML += '&times';

Categories : Jquery

Finding text from text box of user control
It will be easier to write a property to access the TextBox Value Like public string QtyText { get { return txtQty.Text; } } and access using string txtQty = pm.QtyText;

Categories : C#

How do I get the text value entered by a user inside the input text box element?
Bind the change event to the textbox. The reason you see that happening is because the code is already executed by the time the user types a new year. $('#txtYear').on('change', function () { var year = $("#txtYear").val(); console.log(year) }).change(); Refactored var $year = $('#txtYear'); $year.on('change', function () { var year = this.value; console.log(year) }).change();

Categories : Jquery

BeautifulSoup:
spans = soup.find_all('span', attrs={'id':'titleDescriptionID'}) for span in spans: print span.string In your code, wrapper_href.descendants contains at least 4 elements, 2 span tags and 2 string enclosed by the 2 span tags. It searches its children recursively.

Categories : Python

Get text from on click
Yes and try this: $(".like").click(function(event){ event.stopPropagation(); $("i", this).toggleClass("icon-thumbs-up-alt").toggleClass("icon icon-thumbs-up"); console.log($(this).prev('div').find('.hideThis').text()); //Find the previous div relative to the clicked span and insisde that find hideThis }); And remember to close your div, qoutes after the classname postInfo1 and remove quotes in the style value style="display:"none"; Demo

Categories : Javascript

span text on top of image
Try the adding the following: .thumbnail{ position:relative; } .price { color: #fff; font-size: 1.4em; background: #96c42e; padding: 8px 8px 10px 8px; position: absolute; display: block; top:0px; left:auto; right:0px; margin-top: -8px; margin-right: -10px; -moz-transform: rotate(8deg); -webkit-transform: rotate(8deg); -ms-transform: rotate(8deg); z-index:100; } Give the container position:relative then place the price tag using position:absolute.

Categories : CSS

Read text value from span tag
I think you were on the right track. But you should have query not for the text node contained by span, but for the span itself and use XPath axes span = page.find(:xpath,"//input[@class = 'cardFilterItemSelection' and @checked = 'checked']/following-sibling::span[@class = 'itemCount']") value = span.text However I personally find css selectors more readable (unless you need to make complex query) span = page.find(:css, 'input.cardFilterItemSelection[checked=checked] ~ span.itemCount') value = span.text

Categories : Ruby

Text displays behind span
Change the z-index of span as .nav-links a span { z-index: -1 } JSFiddle check this Why does z-index: -1; appear above z-index: 1;?

Categories : CSS

Text in Span overflows Div
Have you tried using other CSS operators such as: white-space:pre; /* or pre-wrap - Text will wrap when necessary, and on line breaks. */ word-wrap:break-word; /* this allows unbreakable words to be broken. */ text-wrap:unrestricted; /* Lines may break between any two characters? */

Categories : Jquery

Show span below text box
span is an inline element, you may want to use a block level element like div or p or set display:block to the span or put a <br/> just before the span.

Categories : CSS



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.