0

I can get all the text inside the other tds, except for td with class="datapid"

  <tr>
     <td class="cregion">JP</td>
     <td class="datacompany"><a href="/company/10644-tecmo">Tecmo</a></td>
     <td class="datapid">P99-00001</td>
     <td class="datapid">4960677070033</td>
     <td class="cdate">02/06/03</td>
     <td class="datarating">&nbsp;</td>
  </tr>

I'm using selenium with PhantomJS 2.1.1:

driver = webdriver.PhantomJS(
"c:/phantomjs-2.1.1-windows/bin/phantomjs.exe")

Trying to get the fields, but only the datapid field is blank:

    cregions = driver.find_elements(
    By.CLASS_NAME, "cregion")
    for region in cregions:
        regions.append(region.text)

    datacompanies = driver.find_elements(
    By.CLASS_NAME, "datacompany")
    for company in datacompanies:
        publishers.append(company.find_element(By.XPATH, "a").text)

    datapids = driver.find_elements(
    By.CLASS_NAME, "datapid")
    for i in range(0, (len(datapids))):
        if i % 2:
            pids.append(datapids[i].text)  //datapids[i].text = ''
1
  • what happens with for pid in datapids: pids.append(pid.text) Commented Jul 16, 2017 at 6:48

1 Answer 1

1

After maximizing the windows:

driver.maximize_window()

now I can get the text inside the div.

I think it is because that the webdriver is not simply reading the source code, but getting it from a windows. If the node is outside the window, it could not be read by webdriver

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.