请选择 进入手机版 | 继续访问电脑版

湖南新梦想

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 57|回复: 0

自动化登录禅道和tinyshop

[复制链接]

25

主题

25

帖子

180

积分

注册会员

Rank: 2

积分
180
发表于 2022-5-23 19:44:01 | 显示全部楼层 |阅读模式
#!/usr/bin/python
# -*- coding: utf-8 -*-

from  selenium import  webdriver
import time
import yaml
from selenium.webdriver.common.by import By

filePath='./config.yaml'
file=open(filePath,'r',encoding='utf-8')
# 加载文件,将文件内容以字典的形式提取出来,yaml.FullLoader表示忽略警告
dt=yaml.load(file,yaml.FullLoader)
# url=dt['url']
# user=dt['user']
# passwd=dt['passwd']
# driver=webdriver.Chrome()
# driver.get(url)
# driver.find_element(By.XPATH,"//*[@id='zentao']").click()
# driver.find_element(By.XPATH,'//*[@id="account"]').send_keys(user)
# driver.find_element(By.XPATH,'//*[@id="loginPanel"]/div/div[2]'
#                              '/form/table/tbody/tr[2]/td/input').send_keys(passwd)
# t=driver.find_element(By.XPATH,'//*[@id="submit"]').text
# driver.find_element(By.XPATH,'//*[@id="submit"]').click()

Turl=dt['Turl']
Tuser=dt['Tuser']
Tpasswd=dt['Tpasswd']
driver=webdriver.Chrome()
driver.get(Turl)
driver.find_element(By.XPATH,"//*[@id='header']/div[1]/div/div[2]/ul/li[7]/a[1]").click()
driver.find_element(By.XPATH,'//*[@id="account"]').send_keys(Tuser)
driver.find_element(By.XPATH,'//*[@id="main"]/div/div/form/ul/li[2]/input').send_keys(Tpasswd)
p=driver.find_element(By.XPATH,'//*[@id="main"]/div/div/form/ul/li[4]/button').text
driver.find_element(By.XPATH,'//*[@id="main"]/div/div/form/ul/li[4]/button').click()
driver.find_element(By.XPATH,'//*[@id="search-keyword"]').send_keys('手机')
driver.find_element(By.XPATH,'//*[@id="search-form"]/button').click()
b=driver.title
print(b)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|湖南新梦想 ( 湘ICP备18019834号-2 )

GMT+8, 2022-6-26 16:53 , Processed in 0.040141 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表