I’m trying to access a toolstrip button in windows forms using button name in windows forms but facing null reference exception as end result. Normally I can invoke button using its name, but i am facing issue in invoke the button in toolstrip button 2. Automation element recognize till toolstrip 1 after adding it can't recognize toolstrip button 2 This issue occur in N unit framework and access button using automation element.I can able to invoke toolstrip button 1 but not toolstrip button 2. Can anyone guide me for this issue ?
Code snippet for accessing button:
    public  void ClickButton()
    {
        object objPattern;
        AutomationElement click = AutomationElement.FindFirst(TreeScope.Descendants,
         new PropertyCondition(AutomationElement.NameProperty, "toolStripButton2"));
        click.TryGetCurrentPattern(InvokePattern.Pattern, out objPattern);
        ((InvokePattern)objPattern).Invoke();
    }
Code snippet for toolstrip:
enter code here
// toolStrip1
        // 
        this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.toolStripButton1,
        this.toolStripComboBox1,
        this.toolStripButton2});
        this.toolStrip1.Location = new System.Drawing.Point(0, 0);
        this.toolStrip1.Name = "toolStrip1";
        this.toolStrip1.Text = "toolStrip1";
        // 
        // toolStripButton1
        // 
        this.toolStripButton1.Name = "toolStripButton1";
        this.toolStripButton1.Text = "toolStripButton1";
        // 
        // toolStripComboBox1
        // 
        this.toolStripComboBox1.Name = "toolStripComboBox1";
        this.toolStripComboBox1.Size = new System.Drawing.Size(121, 25);
        // 
        // toolStripButton2
        // 
        this.toolStripButton2.Name = "toolStripButton2";
        this.toolStripButton2.Text = "toolStripButton2";
        //
    private System.Windows.Forms.ToolStrip toolStrip1;
    private System.Windows.Forms.ToolStripButton toolStripButton1;
    private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
    private System.Windows.Forms.ToolStripButton toolStripButton2;
