Unable to switch tabs in Firefox

29 views
Skip to first unread message

Bhavin Shah

unread,
May 18, 2018, 1:44:51 AM5/18/18
to seleniu...@googlegroups.com
Hello,

I have written a code to verify logged in user name (first+last) but as arrow is there I am not able to do so. Can anyone pls help me out ? (Refer attachment)

Below is the code I have written

String expected = "Anjana2 Sharma";
WebElement rs = driver.findElement(By.xpath(".//*[@id='side-menu']/li[1]/div[1]/a/span/span/strong"));
      String actual = rs.getText();
      if(expected.equals(actual))
        {
      System.out.println("Test Case is Passed");   
        }
          else {
        System.out.println("Test Case is Failed");  
      }

Regards,
Bhavin
ref img -01.jpg

Bhavin Shah

unread,
May 18, 2018, 1:47:28 AM5/18/18
to seleniu...@googlegroups.com
Hello,

I have written a code to verify logged in user name (first+last) but as arrow is there I am not able to do so. Can anyone pls help me out ? (Refer attachment)

Below is the code I have written

String expected = "Anjana Sharma";
WebElement rs = driver.findElement(By.xpath(".//*[@id='side-menu']/li[1]/div[1]/a/span/span/strong"));
      String actual = rs.getText();
      if(expected.equals(actual))
         {
       System.out.println("Test Case is Passed");   
         }
          else {
         System.out.println("Test Case is Failed");  
       }


Regards,
Bhavin
ref img -01.jpg

Bhavin Shah

unread,
May 23, 2018, 4:22:08 AM5/23/18
to seleniu...@googlegroups.com
Hello All,

I have written a code to verify logged in user name (first+last) and whenever I execute the below code fragment it is giving me result 'Test Case is Failed', made many attempts by changing xpath/locator but did not help may be as arrow is there I am unable to do so. How to truncate to take only the text and not downward pointing arrow. Can anyone pls help me out ? (Refer attachment). Also I want to print error/warning messages in console but it is not happening so... How should I work it our ?

Code fragment

String expected = "Anjana Sharma";
WebElement rs = driver.findElement(By.xpath(".//*[@id='side-menu']/li[1]/div[1]/a/span/span/strong"));
String actual = rs.getText();
  if(expected.equals(actual))
         {
       System.out.println("Test Case is Passed");   
         }
          else {
            System.out.println("Test Case is Failed");  
       }


Regards,
Bhavin
ref img -01.jpg

Krishnan Mahadevan

unread,
May 23, 2018, 4:25:55 AM5/23/18
to seleniu...@googlegroups.com

Try with:

 

String actual = ((String) driver.executeScript(“return arguments[0].innerHTML;”, rs)).trim();

 

And see if that helps.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAHp3d75Szz71-g%2B7ZsQ46CWM%2B345g3BOFY-HA5Y5vja_nKZYPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages