Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9056353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:11:07+00:00 2026-06-16T14:11:07+00:00

I need to access the textbox and button ids using selenium webdriver. Since it

  • 0

I need to access the textbox and button ids using selenium webdriver. Since it is placed inside contentplaceholder, webdriver is not able to find the id of the controls. kindly suggest me how to find the controls which are inside the contentplaceholder. i guess i need to give path for this. Your idea will be more helpful.

This is my aspx code:

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<table>
 <tr>
  <td> <asp:Label ID="lblName" runat="server" Text="Name :" ></asp:Label> </td>
  <td> <asp:TextBox ID="txtName" runat="server" 
          ToolTip="Enter your registered user name"></asp:TextBox> </td>

 </tr>
 <tr>  
  <td> <asp:Label ID="lblPwd" runat="server" Text="Password :" ></asp:Label> </td>
  <td> <asp:TextBox ID="txtPwd" runat="server" 
          ToolTip="Enter your registered password"></asp:TextBox> </td>

 </tr>
 <tr>
  <td> 
      <asp:Button ID="btnLogin" runat="server" Text="Login" onclick="btnLogin_Click" 
          ToolTip="Click to Login"/> </td>
  <td> <asp:Label ID="lblWarning" runat="server" Text=" "></asp:Label> </td>
 </tr>
</table>
</asp:Content>

My testproject code is:

[TestMethod()]
    public void TestMethod1()
    {
        //try
        //{
        driver.Navigate().GoToUrl("http://localhost:50294/Login.aspx");
        driver.FindElement(By.Id("txtname")).SendKeys("sachin");            
        driver.FindElement(By.Id("btnLogin")).Click();
        Label lbl = page.FindControl("lblWarning") as Label;
        Assert.AreEqual(lbl, "Inserted successfully");
        }
        catch (Exception er)
        {
            Assert.Fail(er.Message);

        }

    }

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:11:08+00:00Added an answer on June 16, 2026 at 2:11 pm

    Thanks for your reply. But it’s not working in my case.

    However i could able to find a solution for my issue.

    I replaced the textbox and button controls’ ids by the ids which are dynamically generated in the browser in the page source option. now web driver can able to find those controls and inserting values into the textbox.

    This is my new code:

    driver.FindElement(By.Id("MainContent_txtName")).SendKeys("sachin");
    driver.FindElement(By.Id("MainContent_btnLogin")).Click();
    

    The above code works fine 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I need to access the contents of a textbox that is inside a
Possible Duplicate: Need the clientId of a textbox inside a content control using javascript
I need to access the commandline from within a C# application. I can't find
I need to access a RESTful server, which is not created with WCF. For
I need access to the uint64_t typedef from stdint.h in some wrapper code that
I have two different modules that need access to a single file (One will
I've got an app running maximized in a borderless window and need access to
I am working on a theme for Opencart and am finding I need access
I know that's bad design, but I need access to the view from my
I need to access a components tag attribute like: <h:inputtext id=input_age/> from a backing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.