Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc ASP.NETMVC4C#带有PhantomJS和Selenium的登录表单_Asp.net Mvc_Selenium Webdriver_Login_Phantomjs - Fatal编程技术网

Asp.net mvc ASP.NETMVC4C#带有PhantomJS和Selenium的登录表单

Asp.net mvc ASP.NETMVC4C#带有PhantomJS和Selenium的登录表单,asp.net-mvc,selenium-webdriver,login,phantomjs,Asp.net Mvc,Selenium Webdriver,Login,Phantomjs,我有一个特别的问题,因为我不知道如何在selenium.webdriver(phantomjs)中提交没有“id”或“name”的表单有html logim表单: <div class="ui-helper-child-2 ui-page-column-last ui-page-column-span-12"> <div class="ui-page-column-block ui-widget-signin"> <h1>Sign In</h1>

我有一个特别的问题,因为我不知道如何在selenium.webdriver(phantomjs)中提交没有“id”或“name”的表单有html logim表单:

<div class="ui-helper-child-2 ui-page-column-last ui-page-column-span-12">
<div class="ui-page-column-block ui-widget-signin">
  <h1>Sign In</h1>
  <form action="/glo/en-us/session,create/view.html" method="post">
    <div class="ui-helper-child-1">
      <label class="ui-state-required" for="username">Customer ID:</label>
      <input id="username" name="username" maxlength="9" type="text" value="" />
    </div>
    <div class="ui-helper-child-2">
      <label class="ui-state-required" for="password">Password:</label>
      <input id="password" name="password" maxlength="20" type="password" value="" />
    </div>
    <div class="ui-helper-child-3">
      <label class="ui-state-required" for="companyId">Company:</label>
      <select id="companyId" name="companyId">
        <option selected="selected" value="glo">Choose company</option>
        <option value="asp">new to asp</option>
        <option value="aeg">who is it</option>
        <option value="asus">who use this brand name</option>
      </select>
    </div>
    <div class="ui-helper-child-4">
      <input id="callback" name="callback" type="hidden" value="/glo/en-us/home,show/view.html?error=1" />
      <input type="submit" value="Sign In" />
    </div>
  </form>
</div>

登录
客户编号:
密码:
公司:
选择公司
asp的新特性
是谁
谁使用这个品牌名称


还有一次怎么登录?我可以通过webdriver.FindElement(用户名)等向添加信息,但不知道如何发布数据,因为我在提交元素中没有id或名称。

我认为这对您有用:

driver.FindElement(By.CssSelector(".ui-helper-child-4>[type='submit']")).Click();

是的,它很管用。。非常感谢。看来我太懒了,找不到元素。