Skip to main content
Added an explanation.
Source Link
String source = "[[FirefoxDriver: firefox on WINDOWS (4520a9a1-c58b-4b34-ae3e-48613e6e7005)] -> xpath: //div[@class='page-title category-title']]";
System.out.println((source.substring(0, source.length() - 1).split("-> ")[1]));
//Output:
xpath: //div[@class='page-title category-title']
  1. (source.substring(0, source.length() - 1) : this will remove the last element which is ']'(the last square bracket)

  2. split("-> ")[1] : will split the string/element and return it's 1 element.

Improved little bit from @shresth josiSystem.out.println(source.split("-> ")[1]);

Output: xpath: //div[@class='page-title category-title']]

do you see the last ']'? that's the one I'm removing in the first step.

String source = "[[FirefoxDriver: firefox on WINDOWS (4520a9a1-c58b-4b34-ae3e-48613e6e7005)] -> xpath: //div[@class='page-title category-title']]";
System.out.println((source.substring(0, source.length() - 1).split("-> ")[1]));
//Output:
xpath: //div[@class='page-title category-title']

Improved little bit from @shresth josi

String source = "[[FirefoxDriver: firefox on WINDOWS (4520a9a1-c58b-4b34-ae3e-48613e6e7005)] -> xpath: //div[@class='page-title category-title']]";
System.out.println((source.substring(0, source.length() - 1).split("-> ")[1]));
//Output:
xpath: //div[@class='page-title category-title']
  1. (source.substring(0, source.length() - 1) : this will remove the last element which is ']'(the last square bracket)

  2. split("-> ")[1] : will split the string/element and return it's 1 element.

System.out.println(source.split("-> ")[1]);

Output: xpath: //div[@class='page-title category-title']]

do you see the last ']'? that's the one I'm removing in the first step.

Source Link

String source = "[[FirefoxDriver: firefox on WINDOWS (4520a9a1-c58b-4b34-ae3e-48613e6e7005)] -> xpath: //div[@class='page-title category-title']]";
System.out.println((source.substring(0, source.length() - 1).split("-> ")[1]));
//Output:
xpath: //div[@class='page-title category-title']

Improved little bit from @shresth josi