You can’t do this in the WebDriver API, you have to do it in your code. For example:
var textOfA = theAElement.getText();
var textOfSpan = theSpanElement.getText();
var text = textOfA.substr(0, textOfA.length - textOfSpan.length).trim('\n');
Note that the trailing newline is actually part of the text of the <a>
element, so if you don’t want it, you need to strip it.
More Related Contents:
- Can Selenium interact with an existing browser session?
- What is the difference between cssSelector & Xpath and which is better with respect to performance for cross browser testing?
- How to run Selenium WebDriver test cases in Chrome
- Is there a version of Selenium WebDriver that is not detectable?
- Unable to find a matching set of capabilities with selenium 3.4.3, firefox 54.0 and gecko driver 0.17
- Many process of Google Chrome (32 bit)
- How to launch all Karate features setting up which browser to use as an external maven variable
- Reached error page: about:neterror when trying to navigate to other tabs if there is a form submit under that tab
- selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element:
- Refreshing Web Page By WebDriver When Waiting For Specific Condition
- How to download an image using Selenium (any version)?
- Selenium WebDriver how to close browser popup
- Need to find element in selenium by css
- Headless browser detection
- ERROR:ssl_client_socket_openssl.cc(1158)] handshake failed with ChromeDriver Chrome browser and Selenium
- What is the exact purpose of Selenium Grid?
- Cannot get automation extension from timeout: Timed out receiving message from renderer
- How do you click on a checkbox from a list of checkboxes via Selenium/Webdriver in Java?
- org.openqa.selenium.InvalidCookieDomainException: Document is cookie-averse using Selenium and WebDriver
- Selenium Webdriver – click on hidden elements
- Which is the best and fastest way to find the element using webdriver? By.XPath or By.ID or anything else? And why? [closed]
- org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities while initiating Firefox v37 through Selenium v3.11.0
- Selenium how to manage wait for page load?
- selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
- Is there a Selenium WebDriver available for the Microsoft Edge browser?
- Handle windows authentication pop up on Chrome
- How does Selenium WebDriver’s isDisplayed() method work
- what’s the relationship between Selenium RC and WebDriver?
- isElementPresent is very slow in case if element does not exist.
- How to get attribute value inside a div in webdriver