小编meh*_*hdi的帖子

从我的虚拟主机运行一个基于 selenium 的脚本

我有一个从 selenium 生成的 python 脚本,它在我的本地主机上运行良好。

现在我想从我的虚拟主机运行它,我已经检查了我的虚拟主机是否支持 python。

如果不可能,是否有硒的替代解决方案?

# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re

class HellowWorld(unittest.TestCase):
def setUp(self):
    self.driver = webdriver.Firefox()
    self.driver.implicitly_wait(30)
    self.base_url = "https://www.google.com/"
    self.verificationErrors = []
    self.accept_next_alert = True

def test_hellow_world(self):
    driver = self.driver
    driver.get(self.base_url + "/")
    driver.find_element_by_id("lst-ib").clear()
    driver.find_element_by_id("lst-ib").send_keys("hello world")

def is_element_present(self, how, what):
    try: self.driver.find_element(by=how, value=what)
    except NoSuchElementException as e: …
Run Code Online (Sandbox Code Playgroud)

python selenium

5
推荐指数
1
解决办法
1182
查看次数

标签 统计

python ×1

selenium ×1