Beispiel #1
0
    def __init__(self, executable_path, port=0, service_args=None,
                 log_path="geckodriver.log", env=None):
        """Creates a new instance of the GeckoDriver remote service proxy.

        GeckoDriver provides a HTTP interface speaking the W3C WebDriver
        protocol to Marionette.

        :param executable_path: Path to the GeckoDriver binary.
        :param port: Run the remote service on a specified port.
            Defaults to 0, which binds to a random open port of the
            system's choosing.
        :param service_args: Optional list of arguments to pass to the
            GeckoDriver binary.
        :param log_path: Optional path for the GeckoDriver to log to.
            Defaults to _geckodriver.log_ in the current working directory.
        :param env: Optional dictionary of output variables to expose
            in the services' environment.

        """
        log_file = None
        if log_path:
            try:
                log_file = open(log_path, "a+")
            except OSError as e:
                if e.errno != errno.ESPIPE:
                    raise
                log_file = open(log_path, "w")

        BaseService.__init__(
            self, executable_path, port=port, log_file=log_file, env=env)
        self.service_args = service_args or []
Beispiel #2
0
    def __init__(self, executable_path, port=0, service_args=None,
                 log_path="geckodriver.log", env=None):
        """Creates a new instance of the GeckoDriver remote service proxy.

        GeckoDriver provides a HTTP interface speaking the W3C WebDriver
        protocol to Marionette.

        :param executable_path: Path to the GeckoDriver binary.
        :param port: Run the remote service on a specified port.
            Defaults to 0, which binds to a random open port of the
            system's choosing.
        :param service_args: Optional list of arguments to pass to the
            GeckoDriver binary.
        :param log_path: Optional path for the GeckoDriver to log to.
            Defaults to _geckodriver.log_ in the current working directory.
        :param env: Optional dictionary of output variables to expose
            in the services' environment.

        """
        log_file = None
        if log_path:
            try:
                log_file = open(log_path, "a+")
            except OSError as e:
                if e.errno != errno.ESPIPE:
                    raise
                log_file = open(log_path, "w")

        BaseService.__init__(
            self, executable_path, port=port, log_file=log_file, env=env)
        self.service_args = service_args or []
Beispiel #3
0
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.common.service import Service
import unittest
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service

PATH = Service("C:\\Program Files (x86)\\chromedriver.exe")


class OpenSeleniumDocs(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome(service=PATH)

    # first test case for loading page and confirming URL
    def test_openSeleniumWeb(self):
        driver = self.driver
        driver.get("https://www.selenium.dev/")
        driver.maximize_window()
        self.assertIn("Selenium", driver.title)

        assert EC.url_to_be("https://www.selenium.dev/")

    # second test for navigating on pages search and entering for needed element
    def test_searchSeleniumDocs(self):
        driver = self.driver
        driver.get('https://www.selenium.dev/')
        driver.maximize_window()