selenium 百度登陆
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;//引用命名空间
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Selenium2
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
INavigation navigation = driver.Navigate();
navigation.GoToUrl("http://baidu.com");
//IWebElement baiduTextBox = driver.FindElement(By.Id("kw"));
//baiduTextBox.SendKeys("找到文本框");
IWebElement baiduLogin = driver.FindElement(By.LinkText("登录"));
baiduLogin.Click();
System.Threading.Thread.Sleep(3000);
//IWebElement baiduLogin = driver.FindElement(By.XPath("//input[@id='kw']"));
IWebElement userName = driver.FindElement(By.Name("userName"));
IWebElement passWord = driver.FindElement(By.Name("password"));
userName.SendKeys("百度用户名");
passWord.SendKeys("密码");
passWord.Submit();
System.Threading.Thread.Sleep(3000);
//IWebElement getText = driver.FindElement(By.XPath("//span[@class='user-name']"));
IWebElement getText = driver.FindElement(By.XPath("//div[@id='u_sp']"));//mouseMove到那个元素看看 C#
string outPut = getText.Text;
//baiduLogin.SendKeys("爱你");
StreamWriter f = new StreamWriter(@"J:\vs2010_lin_projects\Selenium2\hellolin.txt", false);
f.WriteLine(outPut);
f.Close();
Console.WriteLine(outPut);
Console.ReadKey();
}
}
}
selenium 百度登陆的更多相关文章
- Selenium模拟登陆百度贴吧
Selenium模拟登陆百度贴吧 from selenium import webdriver from time import sleep from selenium.webdriver.commo ...
- Python3 使用selenium库登陆知乎并保存cookie为本地文件
Python3 使用selenium库登陆知乎并保存cookie为本地文件 学习使用selenium库模拟登陆知乎,并将cookie保存为本地文件,然后供以后(requests模块)使用,用selen ...
- selenium 模拟登陆豆瓣,爬取武林外传的短评
selenium 模拟登陆豆瓣,爬去武林外传的短评: 在最开始写爬虫的时候,抓取豆瓣评论,我们从F12里面是可以直接发现接口的,但是最近豆瓣更新,数据是JS异步加载的,所以没有找到合适的方法爬去,于是 ...
- python selenium 模拟登陆百度账号
代码: from selenium import webdriver url = 'https://passport.baidu.com/v2/?login' username = 'your_use ...
- 使用selenium模拟登陆新浪微博
1.selenium基本使用 1.selenium安装及基本操作 selenium是一个自动化测试工具,它支持各种浏览器,包括Chrome,Safari,Firefox等主流界面浏览器驱动,也包括Ph ...
- python selenium模拟登陆163邮箱。
selenium是可以模拟浏览器操作. 有些爬虫是异步加载的,通过爬取网页源码是得不到需要的内容.所以可以模拟浏览器去登陆该网站进行爬取操作. 需要安装selenium通过pip install xx ...
- 使用selenium模拟登陆oschina
Selenium把元素定位接口封装得更简单易用了,支持Xpath.CSS选择器.以及标签名.标签属性和标签文本查找. from selenium.webdriver import PhantomJS ...
- 爬虫实战【10】利用Selenium自动登陆京东签到领金币
今天我们来讲一下如何通过python来实现自动登陆京东,以及签到领取金币. 如何自动登陆京东? 我们先来看一下京东的登陆页面,如下图所示: [插入图片,登陆页面] 登陆框就是右面这一个框框了,但是目前 ...
- python selenium模拟登陆qq空间
不多说.直接上代码 from selenium import webdriver driver = webdriver.Chrome() driver.get('http://qzone.qq.com ...
随机推荐
- 阅读国外大神对this的分析,自己的总结
大神的分析地址:http://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/#comment- ...
- Oracle跨库访问数据表-DBLINK
1:创建DBLINK(USING后面的连接字符串就是要访问的那个数据库的连接字符串) CREATE DATABASE LINK linkName CONNECT TO userName IDENTIF ...
- Math 对象 识记
Math 对象用于执行数学任务. 1.使用 Math 的属性和方法的语法: var pi_value=Math.PI; var sqrt_value=Math.sqrt(15); 注释:Math 对象 ...
- HDU 1517 A Multiplication Game 博弈
题目大意:从1开始Stan与Ollie经行博弈,stan先手,每次将当前数乘上(2~9)间的任意数,最后一次操作后大于等于n的人获胜. 题目思路: 1-9 stan 胜 10-18 ollie胜 19 ...
- dao代码模板
提供数据源以及回收资源的工具类DbUtils: public class DbUtils { private static ComboPooledDataSource dataSource = new ...
- java 生成证书用于https
在jdk的bin目录下运行: keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore " ...
- 运算程序,计算玩判断,Y继续,重复计算,N结束
#include "stdio.h" void main() { /*定义变量,d1,d2:第一.二个数 fu:符号 p1:接收判断号Y/N p2:接收的p1赋给p1 */ int ...
- oracle中110个常用函数介绍
1. ASCII 返回与指定的字符对应的十进制数; SQL> select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from dua ...
- pull类型消息中间件-消息服务端(三)
部署架构 消息存储 存储结构 MetaQ的存储结构是一种物理队列+逻辑队列的结构.如下图所示: Producer生产消息,根据消息的topic选择topic对应某一个分区,然后发送到这个分区对应的Br ...
- android ScrollView中嵌套listview listview可点击处理,可展开
public class MyListView extends ListView { public MyListView(Context context, AttributeSet attrs, in ...