Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium WebDriver Chrome:中的奇怪行为--窗口大小=x,y“;具有微小尺寸x/y的模式_Python_Selenium Webdriver_Selenium Chromedriver_Chrome Options - Fatal编程技术网

Python Selenium WebDriver Chrome:中的奇怪行为--窗口大小=x,y“;具有微小尺寸x/y的模式

Python Selenium WebDriver Chrome:中的奇怪行为--窗口大小=x,y“;具有微小尺寸x/y的模式,python,selenium-webdriver,selenium-chromedriver,chrome-options,Python,Selenium Webdriver,Selenium Chromedriver,Chrome Options,我正在通过SeleniumWebDriverChrome Python options = webdriver.ChromeOptions() options.add_argument("--window-size=100,100") driver = webdriver.Chrome(ChromeDriverManager().install(), options=go.options) driver.get("https

我正在通过
Selenium
WebDriver
Chrome

Python

    options = webdriver.ChromeOptions()
    options.add_argument("--window-size=100,100")
    
    driver = webdriver.Chrome(ChromeDriverManager().install(), options=go.options)
    driver.get("https://somepage")
    wait = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.TAG_NAME, 'a')))
    
    try:
                list_links = driver.find_elements_by_tag_name('a')
    except Exception:
                print("No links")
                list_links = list()
                pass
    
    if list_links:
       link_ = random.choice(list_links)
       try:
          page_ = link_.text
          if page_ not in self.site_exclude:
                        link_.click()
                        self.counter += 1
                        print(self.counter, page_)
       except Exception as Err:
          print("Bad link", Err)
    else:
       print("list empty")
例如,
--window size=500500
或更多时,此代码正常工作,也不使用此选项。 但随着时间的推移,
--窗口大小=100100
-(事实上,它不会在打开的Chrome窗口中显示页面的任何部分,只在浏览器的上方栏中显示),它会使用带有空数据的
元素。(但假设DOM加载正常。)

它返回list
list\u links=driver.find\u elements\u by\u tag\u name('a')
和通常的对象集;它的数量-是确定的

但是所有列表元素中的内容属性都为空:例如
list\u links[any]。text='
。在realty中,此html页面中的所有
-tags
都有一些文本

看起来,如果浏览器在屏幕上没有真正显示页面内容,它不会加载某些html标记中的所有页面内容,而是正确加载元素的DOM

(这对我的工作来说并不是一个严重的问题,但我真的对这个事实感到惊讶。)