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 百度登陆的更多相关文章

  1. Selenium模拟登陆百度贴吧

    Selenium模拟登陆百度贴吧 from selenium import webdriver from time import sleep from selenium.webdriver.commo ...

  2. Python3 使用selenium库登陆知乎并保存cookie为本地文件

    Python3 使用selenium库登陆知乎并保存cookie为本地文件 学习使用selenium库模拟登陆知乎,并将cookie保存为本地文件,然后供以后(requests模块)使用,用selen ...

  3. selenium 模拟登陆豆瓣,爬取武林外传的短评

    selenium 模拟登陆豆瓣,爬去武林外传的短评: 在最开始写爬虫的时候,抓取豆瓣评论,我们从F12里面是可以直接发现接口的,但是最近豆瓣更新,数据是JS异步加载的,所以没有找到合适的方法爬去,于是 ...

  4. python selenium 模拟登陆百度账号

    代码: from selenium import webdriver url = 'https://passport.baidu.com/v2/?login' username = 'your_use ...

  5. 使用selenium模拟登陆新浪微博

    1.selenium基本使用 1.selenium安装及基本操作 selenium是一个自动化测试工具,它支持各种浏览器,包括Chrome,Safari,Firefox等主流界面浏览器驱动,也包括Ph ...

  6. python selenium模拟登陆163邮箱。

    selenium是可以模拟浏览器操作. 有些爬虫是异步加载的,通过爬取网页源码是得不到需要的内容.所以可以模拟浏览器去登陆该网站进行爬取操作. 需要安装selenium通过pip install xx ...

  7. 使用selenium模拟登陆oschina

    Selenium把元素定位接口封装得更简单易用了,支持Xpath.CSS选择器.以及标签名.标签属性和标签文本查找. from selenium.webdriver import PhantomJS ...

  8. 爬虫实战【10】利用Selenium自动登陆京东签到领金币

    今天我们来讲一下如何通过python来实现自动登陆京东,以及签到领取金币. 如何自动登陆京东? 我们先来看一下京东的登陆页面,如下图所示: [插入图片,登陆页面] 登陆框就是右面这一个框框了,但是目前 ...

  9. python selenium模拟登陆qq空间

    不多说.直接上代码 from selenium import webdriver driver = webdriver.Chrome() driver.get('http://qzone.qq.com ...

随机推荐

  1. HDU 3294 Girls' research

    题目地址 manacher #include<cstdio> #include<string.h> #include<algorithm> using namesp ...

  2. 使用webview加载html图片、表单超屏幕问题

    webView加载html代码时,使用webView自带的 scalesPageToFit 可以解决图片所带来的超过屏幕问题:但是,所带来的问题就是文字变小了,怎样让图片边小,并且文字还是原来html ...

  3. spark-2.0.0与hive-1.2.1整合

    SparkSQL与Hive的整合 1. 拷贝$HIVE_HOME/conf/hive-site.xml和hive-log4j.properties到 $SPARK_HOME/conf/ 2. 在$SP ...

  4. JS实现点击弹出对应的索引

    如果这样写的话 ,弹出来一直是2,原因 这个i ,循环已经结束,i 的值已经是2了,所以需要再前面添加: items[i].index=i;    //添加一个属性  ,技术一下 这个索引值 aler ...

  5. 自定义按钮~自适应布局~常见bug

    一.元件 自定义按钮可用button或a   display为 inline-block 方便设置格式,通过 padding,height,line-height,font-size设置按钮的大小 & ...

  6. 淘淘商城_day03_课堂笔记

    今日大纲 实现商品的编辑 实现商品的规格参数功能 搭建前台系统 实现首页商品类目的显示 商品的编辑 数据的编辑核心是:数据回显. 编辑按钮事件 判断选中的行数 弹出window 加载编辑页面,在页面加 ...

  7. java 读取excel(Map结构)xls

    package com.sun.test; import java.io.FileInputStream;import java.io.FileNotFoundException;import jav ...

  8. Hoffmann树

    数据压缩编码 先把两棵二叉树简化成叶子结点带权的二叉树,图的每个结点之间带有权值 结点的路径长度: 从根结点到该结点的路径上的连接数. 树的路径长度: 树中每个叶子结点的路径长度之和. 结点带权路径长 ...

  9. Python之生产者&、消费者模型

    多线程中的生产者和消费者模型: 生产者和消费者可以用多线程实现,它们通过Queue队列进行通信. import time,random import Queue,threading q = Queue ...

  10. deb

    1.APT方式 (1)普通安装:apt-get install softname1 softname2 …; (2)修复安装:apt-get -f install softname1 softname ...