Я записал scipt в Java с Webdriver, и он хорошо работал, и ниже код для образца
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;
import com.thoughtworks.selenium.Selenium;
import java.util.*;
import java.lang.Thread.*;
public class Login {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, "http://192.168.10.10:8080/");
selenium.open("/");
selenium.keyPress("name=user_id", "admin");
}
}
}
Но мое требование состоит в том, чтобы реализовать то же в Python с webdriver, можете Вы сообщать мне, как это может быть, покончили вышеупомянутый пример и webdriver двоичные файлы и как сделать установку для того же
Вы читали инструкции в привязки python для WebDriver ?
example2.py
понятны, хотя и не являются прямым переводом вашего кода:
import unittest
from google_one_box import GoogleOneBox
from selenium.firefox.webdriver import WebDriver
class ExampleTest2(unittest.TestCase):
"""This example shows how to use the page object pattern.
For more information about this pattern, see:
http://code.google.com/p/webdriver/wiki/PageObjects
"""
def setUp(self):
self._driver = WebDriver()
def tearDown(self):
self._driver.quit()
def testSearch(self):
google = GoogleOneBox(self._driver, "http://www.google.com")
res = google.search_for("cheese")
self.assertTrue(res.link_contains_match_for("Wikipedia"))
if __name__ == "__main__":
unittest.main()
Тестовый модуль GoogleOneBox моделирует страницу с панелью поиска Google (буква u рл немного сдвинулся).