如何解决无法在Visual Studio代码中运行Selenium IDE Python代码
将记录的Selenium IDE测试导出到.py文件,然后在Visual Studio Code中打开它后,运行该文件似乎没有任何反应。
终端中唯一显示的是: “ PS C:\ Users \ User>和python c:/Users/User/Desktop/test1.py”
代码如下:
# 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 test1():
def setup_method(self,method):
self.driver = webdriver.Chrome()
self.vars = {}
def teardown_method(self,method):
self.driver.quit()
def test1(self):
self.driver.get("http://192.168.5.1/")
self.driver.set_window_size(1123,824)
self.driver.switch_to.frame(1)
self.driver.find_element(By.NAME,"f_username").click()
self.driver.find_element(By.NAME,"f_username").send_keys("Administrator")
self.driver.find_element(By.NAME,"pwd").send_keys("Administrator")
self.driver.find_element(By.CSS_SELECTOR,".submitBtn").click()
关于Visual Code为什么不显示任何特定错误而只写以下内容的任何想法:“ PS C:\ Users \ User>和python c:/Users/User/Desktop/test1.py”?
我猜它缺少开始执行代码的行,我该怎么做?
非常感谢, 托马斯
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。