Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362965

Summary: Wrong warning with hint to make this ... access statically
Product: [Eclipse Project] JDT Reporter: LKWG82 <lkwg82>
Component: CoreAssignee: Jesper Moller <jesper>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, daniel_megert, lkwg82, markus.kell.r, srikanth_sankaran
Version: 3.8   
Target Milestone: 4.3 M6   
Hardware: PC   
OS: Linux   
Whiteboard:

Description LKWG82 CLA 2011-11-05 06:57:22 EDT
Build Identifier: 20110916-0149

static fluent interface:

webdriver.findElement(By.id("profil_header").xpath("/h1")).getText()

-> 
By.id("profil_header").xpath("/h1");

see api http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html

Reproducible: Always

Steps to Reproduce:
1. 

import org.openqa.selenium.By;

public class Bug{
public static  void main(String[] args){
   By.id("profil_header").xpath("/h1");
}
}

2. see the warning
Comment 1 Markus Keller CLA 2011-11-07 13:01:01 EST
Can you explain why you think the warning is wrong?

By#xpath(String) is a static method, so

    By.id("profil_header").xpath("/h1")

is equivalent to

    By.xpath("/h1")

, unless the execution of By#id(String) changes some global state, which would be quite bad style and is not documented.

Moving to JDT Core to close.
Comment 2 Ayushman Jain CLA 2011-11-09 00:09:53 EST
Agree with Markus. I intend to close as invalid.

By.id("profil_header") returns a new object, from which the static function xpath("/h1") is being invoked. This warning is indeed meant to catch cases such as these.
Comment 3 Jesper Moller CLA 2013-03-11 19:55:45 EDT
Agreed, closing as invalid.

FWIW, the intended WebDriver usage would be:

webdriver.findElement(By.id("profil_header")).findElement(By.xpath("/h1")).getText()