Selenium returns empty string instead of the actual data

selenium text returns empty string python
protractor gettext returns empty string
gettext trim selenium
gettext is not working
gettext in selenium
how to use gettext selenium
get element text selenium
webdriver gettext javascript

I am using Selenium via Python in attempts to web scrape. I'm almost where I want to be but I ran into what I am now realizing is not so small of a problem. So the element I am working with is this:

<td class=" ui-datepicker-days-cell-over  ui-datepicker-current-day ui-datepicker-today" 
data-handler="selectDay" data-event="click" data-month="3" data-year="2018">
    <a class="ui-state-default ui-state-highlight ui-state-active" href="#">10
    </a>
</td>

My ultimate goal is to get the 10 that's between the a tags. This is my code so far:

option = selenium.webdriver.ChromeOptions()
option.add_argument(" - incognito")
browser = webdriver.Chrome(executable_path=r"chromedriver.exe")
browser.get(myUrl)
calendar = browser.find_element_by_xpath(
    '/html/body/main/section/div[2]/div[1]/div[2]/div[3]/div/div[1]/div/div[1]/div[2]')
viewCal = browser.find_element_by_name('choice_set[begin_at]')
viewCal.click()

row = calendar.find_elements_by_tag_name('tr')

column = calendar.find_elements_by_tag_name('td')
numb = column[0].find_element_by_tag_name('a')
numb.text

numb.text returns '' instead of 10.

What am I doing wrong here?

Try to use the following code:

numb.get_attribute("innerText")

getText() method of selenium chrome driver sometimes returns an , GetText method returns empty string for invisible element #6415 Modify the attached java class (SeleniumBug.java) to point to the HTML page (modify the variable 'URL'). Modifier Name, ND: Network Reference] Actual: [D: Creation, D​: Status Date, I need to fetch the data inside the table whatever it is visible or not. I have a scenario like clicking on the images of home page and validating page title. I am facing an issue say I am using the getTitle() function to get a page title to validate but it's returning the current URL, so my test case failed by comparing with the page title. Here's my question: Why is it returning a current URL instead of a page title?

I think you don't select the right WebElements in your code.

I tried the following code with a similar datepicker and it was printing the expected daynumber.

days = driver.find_elements_by_xpath('//a[@class="ui-state-default"]')
daynumber = days[12].text
print(daynumber)

GetText method returns empty string for invisible element · Issue , Actual result: if we have 50 rows and grid height cont. for element, but if try getText for actual invisible element, getText() return empty string again. -​elements-using-selenium-webdriver/ Which mentions using attributes instead: textContent,  There are two types of HTML tables published on the web- Static tables: Data is static i.e. Number of rows and columns are fixed. Dynamic tables: Data is dynamic i.e. Number of rows and columns are NOT fixed. Below is an example of a dynamic table of Sales. Based on input date filters, number of rows will get altered. So, it is dynamic in nature.

(Posted answer on behalf of the question author.)

I am very confused about why this is so but I guess I went in too deep. I skipped the last two steps of my code and finished with column[0].text instead and that worked! Also as Ratmir answered on the bottom numb.get_attribute("innerText") also gives the correct answer.

getText return empty result for first invisible row in GWT DataGrid , getText() returns an empty string sometimes, but when it happens and I take a in my experience sometimes selenium tries to read even before page is loaded so I It is true when I get the text, false when getText() comes back empty. Warning: <a> proprietary attribute "data-xtooltip-click-disable" The WebDriver is automatically closed, when this node is being reset, or the workflow or KNIME is closed. Additionally, you can explicitly close the browser with a Quit WebDriver node. Important note: Because of the way Selenium works, KNIME workflows using the Selenium Nodes behave differently

WebElement..getText() sometimes returns empty string when , getText() sometimes returns empty string when screenshot shows string not empty element is mediated by javascript to look bigger than the normal select, and rather than trying to definitely put the DOM (and Selenium) in a bad state. TidyHTML complains about things like qa-data-locator because it is What is Selenium WebDriver? Selenium is used for website testing. Instead of a person manually opening a browser and using a mouse to select something on the page we can use Selenium WebDriver to do this for us. It uses a "driver" to open up your browser of choice, find elements on the page and interact with them. Why Automated Testing?

Re: WebElement..getText() sometimes returns empty string when , Instead string is a class which is present in java.lang package which or having sequence of characters. if the string is empty then returns true  The getAttribute () method of the Element interface returns the value of a specified attribute on the element. If the given attribute does not exist, the value returned will either be null or "" (the empty string); see for details.

Use of Strings in Selenium WebDriver Examples, Build data-driven test frameworks for mobile and web applications with Selenium Web setCapability("marionette", true); // then pass getInstance() { if ( instance == null ) { instance = new CreateDriver(); } return instance; } public final void setDriver(String browser, String platform, String environment, Map<String, Object​>. It is returning the object type and not the actual data. Below is the code. public void addImage(byte [] buffer) {MySql.Data.MySqlClient. MySqlConnection conn; string sql = ""; //Here checked the byte array length and it returned the correct numbers //The data field is a LONG BLOB and works fine with an uploaded image

Comments
  • So, how is going? Did you try my answer?
  • It is returning None :( Do you have any idea why this might be so?
  • @Chae I changed my answer can you check it again