Python无法使用Selenium识别表单元格中的文本

时间:2019-03-04 06:45:25

标签: python python-3.x selenium selenium-webdriver selenium-chromedriver

在我的Python程序中...最后一条语句没有打印出来,而是留下一行空行。这是我的程序:

As discussed in <a href=#the-problem>section "The problem"</a> ....

我得到的输出是:

from selenium import webdriver 
from selenium.webdriver.support.select import Select

print('Automated login for MDPI80X03 Started!')

driver=webdriver.Chrome() 
print('Chrome launched!')
driver.get(url)
print('Login successful!')

print('Timetable Loaded!')

print(driver.find_element_by_id('caccp1_header_clblHeader1').text)

print(driver.find_element_by_xpath('//table[@id="caccp1_content_clblContent1"]/tbody/tr[2]/td[2]').text)

点击此处:Inspect Element

1 个答案:

答案 0 :(得分:1)

您尝试提取的元素被隐藏,其中一个祖先具有属性#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main() { FILE *fileptr; char filechar[1024]; long siz; printf("Enter file name : "); if (scanf("%1023s", filechar) != 1) { fprintf(stderr, "invalid input\n"); return 1; } printf("please enter size"); if (scanf("%ld", &siz) != 1) { fprintf(stderr, "invalid input\n"); return 1; } fileptr = fopen(filechar, "a+"); if (fileptr == NULL) { fprintf(stderr, "cannot open file %s: %s\n", filechar, strerror(errno)); return 1; } if (ftruncate(fileno(fileptr), siz)) { fprintf(stderr, "cannot truncate file %s: %s\n", filechar, strerror(errno)); fclose(fileptr); return 1; } fclose(fileptr); return 0; } 。要获取文本,您需要使用JavaScript命令

style="display: block; height: auto; overflow: hidden;"