I have tested a selenium test to download file from website in selenium IDE
. then I have exported this test as python script.
But I dont know how to use this script in a python code.
Here is the output script:
# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class Test201401():
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_201401(self):
time.sleep(10000)
self.driver.get("LINK to My Download")
self.driver.set_window_size(550, 691)
time.sleep(5000)
elements = self.driver.find_elements(By.ID, "kc-form")
assert len(elements) > 0
self.driver.find_element(By.ID, "username").click()
self.driver.find_element(By.ID, "username").send_keys("myusername")
self.driver.find_element(By.ID, "password").send_keys("mypasswor")
self.driver.find_element(By.ID, "kc-login").click()
time.sleep(5000)
I have installed pytest
and selenium
by pip3
in windows. Nothing happens after running this script . no Error and no Download!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…