Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 views
in Technique[技术] by (71.8m points)

使用python+selenium模拟手工操作网页,本地运行正常,服务器上面报错找不到元素

            label   = self.client.find_element_by_xpath('/html/body/div[1]/div/div[1]/div/div[2]/div[2]/div[3]/form/div/div/div/div/input')
            rand    = random.randint(362, 368) / 10
            randStr = '%.1f'%rand
            print('old:'+label.get_attribute('value')+'rand:'+randStr)
            label.clear()
            label.send_keys(randStr)
            time.sleep(1)
            print('new:'+label.get_attribute('value'))
        
        然后点击按钮后,拿不到弹窗

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

selenium是需要有真正的浏览器的,你的服务器是LINUX吧,那如果没有安装图形界面就没有浏览器。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...