Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362965 - Wrong warning with hint to make this ... access statically
Summary: Wrong warning with hint to make this ... access statically
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.3 M6   Edit
Assignee: Jesper Moller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-05 06:57 EDT by LKWG82 CLA
Modified: 2013-03-11 20:10 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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()