class AddAToDoText(unittest.TestCase):
    def setUp(self):
        options = EdgeOptions()
        options.use_chromium = True
        options.binary_location = "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe"
        dir = os.path.dirname(os.path.realpath(__file__))
        edge_driver_path = dir + "\\edgedriver_win64\\msedgedriver.exe"
        self.service = Service(edge_driver_path)
        self.service.start()
        self.driver = Edge(options=options, service=self.service)
        self.driver.implicitly_wait(30)
        self.driver.maximize_window()
        self.driver.get("http://*****:*****@class='toggle']/following-sibling::label").get_attribute(
                "innerText")
        self.assertEqual("The test is adding this todo", addedToDoText)

    def tearDown(self):
        self.driver.quit()
        self.service.stop()
Esempio n. 2
0
def update():
    print("spider update")
    service = Service('D:\ProgramData\Anaconda3\Scripts\msedgedriver.exe')
    service.start()
    driver = webdriver.Remote(service.service_url)
    driver.get('http://weather.sina.com.cn')
    data = driver.find_elements_by_class_name('slider_degree')[0]
    print(data.text)
    driver.quit()
 def setUp(self):
     options = EdgeOptions()
     options.use_chromium = True
     options.binary_location = "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe"
     dir = os.path.dirname(os.path.realpath(__file__))
     edge_driver_path = dir + "\\edgedriver_win64\\msedgedriver.exe"
     self.service = Service(edge_driver_path)
     self.service.start()
     self.driver = Edge(options=options, service=self.service)
     self.driver.implicitly_wait(30)
     self.driver.maximize_window()
     self.driver.get("http://localhost:4200")
class HeaderText(unittest.TestCase):
    def setUp(self):
        options = EdgeOptions()
        options.use_chromium = True
        options.binary_location = "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe"
        dir = os.path.dirname(os.path.realpath(__file__))
        edge_driver_path = dir + "\\edgedriver_win64\\msedgedriver.exe"
        self.service = Service(edge_driver_path)
        self.service.start()
        self.driver = Edge(options=options, service=self.service)
        self.driver.implicitly_wait(30)
        self.driver.maximize_window()
        self.driver.get("http://localhost:4200")

    def test_HeaderText(self):
        headerText = self.driver.find_element(By.CSS_SELECTOR,
                                              "h1").get_attribute("innerText")
        self.assertEqual("todos", headerText)

    def tearDown(self):
        self.driver.quit()
        self.service.stop()
Esempio n. 5
0
    def __init__(self,
                 executable_path='MicrosoftWebDriver.exe',
                 capabilities=None,
                 port=DEFAULT_PORT,
                 verbose=False,
                 service_log_path=None,
                 log_path=DEFAULT_SERVICE_LOG_PATH,
                 service=None,
                 options=None,
                 keep_alive=False,
                 is_legacy=True,
                 service_args=None):
        """
        Creates a new instance of the edge driver.
        Starts the service and then creates new instance of edge driver.

        :Args:
         - executable_path - Deprecated: path to the executable. If the default is used it assumes the executable is in the $PATH
         - capabilities - Dictionary object with non-browser specific capabilities only, such as "proxy" or "loggingPref".
           Only available in Legacy mode
         - port - Deprecated: port you would like the service to run, if left as 0, a free port will be found.
         - verbose - whether to set verbose logging in the service. Only available in Legacy Mode
         - service_log_path - Deprecated: Where to log information from the driver.
         - keep_alive - Whether to configure EdgeRemoteConnection to use HTTP keep-alive.
         - service_args - Deprecated: List of args to pass to the driver service
         - is_legacy: Whether to use MicrosoftWebDriver.exe (legacy) or MSEdgeDriver.exe (chromium-based). Defaults to True.
         """
        if not is_legacy:
            executable_path = "msedgedriver"

        service = service or Service(executable_path,
                                     port=port,
                                     verbose=verbose,
                                     log_path=service_log_path,
                                     is_legacy=is_legacy)

        super(WebDriver, self).__init__(executable_path, port, options,
                                        service_args, DesiredCapabilities.EDGE,
                                        service_log_path, service, keep_alive)
def main():
    start_time = time.time()
    print("Reading profile path")
    file = open("PROFILE_PATH", "r")
    parameter1 = file.readline()
    parameter2 = file.readline()
    file.close()
    edge_options = EdgeOptions()
    edge_options.use_chromium = True
    #edge_options.add_argument("-inprivate")
    edge_options.add_experimental_option(
        "detach", True)  # Keep browser open after the program finishes running
    argument1 = "user-data-dir=" + parameter1
    edge_options.add_argument(argument1)
    argument2 = "profile-directory=" + parameter2
    edge_options.add_argument(argument2)
    path = Service("msedgedriver.exe")
    browser = Edge(service=path, options=edge_options)
    browser.get("https://account.microsoft.com/rewards/")

    # Wait for manual login
    print(" _                 _      ___     __         __  __  ")
    print("| |               (_)    |__ \   / /        / /  \ \ ")
    print("| |     ___   __ _ _ _ __   ) | | |_   _   / / __ | |")
    print("| |    / _ \ / _` | | '_ \ / /  | | | | | / / '_ \| |")
    print("| |___| (_) | (_| | | | | |_|   | | |_| |/ /| | | | |")
    print("|______\___/ \__, |_|_| |_(_)   | |\__, /_/ |_| |_| |")
    print("              __/ |              \_\__/ |        /_/")
    print("             |___/                 |___/            ")
    print("Login? (y/n)")
    cmd = input()
    if cmd == "y" or cmd == "Y":
        open_tabs(browser)
        elapsed_time = time.time() - start_time
        print("Search Completed in " + str(elapsed_time) + "s. Script ends.")
    else:
        print("Script ends.")
Esempio n. 7
0
    def __init__(self,
                 executable_path='MicrosoftWebDriver.exe',
                 capabilities=None,
                 port=DEFAULT_PORT,
                 verbose=False,
                 service_log_path=None,
                 log_path=DEFAULT_SERVICE_LOG_PATH,
                 service=None,
                 options=None,
                 keep_alive=False):
        """
        Creates a new instance of the chrome driver.

        Starts the service and then creates new instance of chrome driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
         - capabilities - Dictionary object with non-browser specific
           capabilities only, such as "proxy" or "loggingPref".
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - verbose - whether to set verbose logging in the service
         - service_log_path - Where to log information from the driver.
         - keep_alive - Whether to configure EdgeRemoteConnection to use HTTP keep-alive.
         """
        if port != DEFAULT_PORT:
            warnings.warn(
                'port has been deprecated, please pass in a Service object',
                DeprecationWarning,
                stacklevel=2)
        self.port = port

        if service_log_path != DEFAULT_SERVICE_LOG_PATH:
            warnings.warn(
                'service_log_path has been deprecated, please pass in a Service object',
                DeprecationWarning,
                stacklevel=2)
        if capabilities is not None:
            warnings.warn(
                'capabilities has been deprecated, please pass in a Service object',
                DeprecationWarning,
                stacklevel=2)
        if service_log_path != DEFAULT_SERVICE_LOG_PATH:
            warnings.warn(
                'service_log_path has been deprecated, please pass in a Service object',
                DeprecationWarning,
                stacklevel=2)
        if verbose:
            warnings.warn(
                'verbose has been deprecated, please pass in a Service object',
                DeprecationWarning,
                stacklevel=2)

        if service:
            self.service = service
        else:
            self.service = Service(executable_path,
                                   port=self.port,
                                   verbose=verbose,
                                   log_path=service_log_path)
        self.service.start()

        if capabilities is None:
            capabilities = DesiredCapabilities.EDGE

        RemoteWebDriver.__init__(self,
                                 command_executor=RemoteConnection(
                                     self.service.service_url,
                                     resolve_ip=False,
                                     keep_alive=keep_alive),
                                 desired_capabilities=capabilities)
        self._is_remote = False
Esempio n. 8
0
def start_webdriver():
    print("Starting webdriver...")
    driver = webdriver.Edge(
        service=Service(EdgeChromiumDriverManager().install()))
    return driver
Esempio n. 9
0
import time
from selenium import webdriver
from selenium.webdriver.common import service
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
from bs4 import BeautifulSoup
import xlsxwriter

edge_options = Options()
edge_service = Service("C:\Program Files (x86)\Microsoft\Edge\Application\msedgedriver.exe")
edge_options.add_argument("headless")
driver = webdriver.Edge(service=edge_service)
driver.get("https://store.steampowered.com/search/?sort_by=_ASC&ignore_preferences=1&filter=topsellers")
time.sleep(2)
scroll_pause_time = 1
screen_height = driver.execute_script("return window.screen.height;")
i = 1

workbook = xlsxwriter.Workbook('SteamGames.xlsx')
worksheet = workbook.add_worksheet()
bold = workbook.add_format({'bold':True})

worksheet.write('A1', 'Name', bold)
worksheet.write('B1', 'Price', bold)
worksheet.write('C1', 'Release Date', bold)
worksheet.write('D1', 'Publisher', bold)
worksheet.write('E1', 'Developer', bold)
worksheet.write('F1', '% Positive Reviews (30 days)', bold)
worksheet.write('G1', 'Total Number Reviews (30 days)', bold)
worksheet.write('H1', '% Positive Reviews (All Time)', bold)
worksheet.write('I1', 'Total Number Reviews (All Time)', bold)