SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.5k stars 8.15k forks source link

since v3.5 selenium and IEdriver on webdriverio elementIdText(elementArray[0]) returns the whole array #5626

Closed xywang68 closed 4 years ago

xywang68 commented 6 years ago

Meta -

OS:
Windows 7 Selenium Version:
3.5.0 Browser:
Internet Explorer 11 Browser Version:
11.0.9600.16428IS Updated Versins: RTM (KB2841134)

I have filed this issue under webdriverio, but after more debugging I found this issue is related to seleenium and IEDriver from 3.5 and on. selenium and IEDriver 3.4 worked as expected. Also chromeDriver 2.36 does not show this issue for selenium 3.5 and on up to 3.11.

All debug data is filed in this webdriverio issue: https://github.com/webdriverio/webdriverio/issues/2641

Expected Behavior -

elementIdText(elementArray[0]) to return the text of of the first element, in this case 'All'

Actual Behavior -

  1. elementIdText(elementArray[0]) returned the elementArray;
  2. the for the subsequent array elements it returned the text for the last element (offset by 1).

Steps to reproduce -

See the webdriverio issue 2641 mention aboved.

jimevans commented 6 years ago

This looks suspiciously like a difference between the OSS and W3C dialects of the wire protocol. 3.5 is when the IE driver began using the W3C WebDriver Specification compliant version of the protocol. What happens when you perform the same test using Firefox with geckodriver? If you get the same behavior as the IE driver (version >= 3.5), then there's something iffy about what WebdriverIO is doing in its manipulation.

xywang68 commented 6 years ago

Hi, @jimevans , I didn't test with Firefox, but I tested with Chrome 65 against Selenium 3.5 - 3.11 and it is working fine (not the same behavior as IE). Do you think this is good enough of indication for what you are suspecting?

jimevans commented 6 years ago

@xywang68 No, that’s not sufficient. The reason is that geckodriver, like the IE driver after 3.5, implements the W3C WebDriver spec. Chromedriver doesn’t. If WebdriverIO produces the same or similar results using Firefox with geckodriver, it’s far more an indication that we need to examine how WebdriverIO implements spec-compliant communication. If it doesn’t produce a similar result, the next step is to strip the case down to its bare essentials, using one of the language bindings provided by the Selenium project (not necessarily JavaScript).

xywang68 commented 6 years ago

@jimevans , Thank you for your response. I will run a FF test and provide test data soon, maybe even today.

xywang68 commented 6 years ago

@jimevans , I managed to test with Selenium 3.4.0 and 3.11.0, with Firefox 59.0.1 x32 and FFDriver 0.19.1, and got the expected result (same as Chrome). I updated the test data to the referenced ticket (webdriverio issue 2641). I have upload the log file for selenium 3.4.0 and 3.11.0 on FF to the same gist in the reference ticket. For 3.11.0 it logged a lot of javascript errors and and the log file does not have too much test information, however the test passed. There are 4 sub files in the gist, please look out for them selenium-3.11.0-chrome (test passed) selenium-3.11.0-IE (test failed) selenium-3.4.0-FF (test passed) selenium-3.11.0-FF with error (test passed)

jimevans commented 6 years ago

@xywang68 Okay, then as I said, the next step is to create a stripped-down reproduction case (including page against which to run the test) using one of the project-provided bindings.

xywang68 commented 6 years ago

Hi, @jimevans , I am willing to help create such case towards the resolving of this issue. However, I am not familiar with "project-provided bindings", where can I find such information?

jimevans commented 6 years ago

@xywang68 What I mean is creating a repro case using any of the language bindings provided by the Selenium project (Java, .NET, Python, Ruby, or the Selenium JavaScript bindings). The important thing is to be able to repro the issue outside of using WebdriverIO.

xywang68 commented 6 years ago

@jimevans , I understand now, and will do so. It may take a bit more time. I will ping you when I submit the test case repo.

barancev commented 6 years ago

Closing the issue as there is no reproduction scenario provided.

xywang68 commented 6 years ago

@jimevans and @barancev Sorry for the delayed response. I am able to reproduce the case using the basic binding, and demonstrated that in selenium 3.4.0 it is still good, and in selenium 3.5.0 it starts to show the bug. Here is what I have done:

  1. create a sample test.html
  2. use selenium-webdriver npm package
  3. wrote a simple test.js that will demonstrate the problem
  4. run the a test against selenium-standalone 3.4.0 + IEDriver 3.4.0 to show the expected result
  5. run the same test against selenium-standalone 3.5.0 + IEDriver 3.4.0 which demonstrated the bug

and uploaded all the sample HTML file, test script, logs for both positive and negative as well as all version information to https://gist.github.com/xywang68/dac2bb83caec84c72e44edae508266e1

I think I have supplied enough good information for you. Please review, and please reopen this issue. Thank you.

luke-hill commented 6 years ago

@xywang68 - TO use bindings 3.5 or greater, you must use 3.5 or greater of the IEDriver. In your gist examples for Webdriver 3.5 you're using IEDriver 3.4

See: https://github.com/SeleniumHQ/selenium/blob/master/cpp/iedriverserver/CHANGELOG#L367

jimevans commented 6 years ago

@xywang68 I've taken your HTML page and translated your example code to the following C# code:

// Also used IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub", new InternetExplorerOptions());
IWebDriver driver = new InternetExplorerDriver();
StringBuilder builder = new StringBuilder();
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("optionTextTest.html");
ReadOnlyCollection<IWebElement> options = driver.FindElements(By.XPath("//option"));
foreach (IWebElement option in options)
{
    builder.AppendLine(option.Text);
}

Console.WriteLine(builder.ToString());

When run using the latest .NET bindings (3.11.1) and the latest IE driver (3.11.1.5), the following text is printed:

All
Deal
Loan
Performance
Performance - MBA
Performance - OTS
Loss and Liq
Prepayments
Modifications
Property
Servicer Advances

To me, this looks like the proper and expected output. This is the output found both running this via driver executable itself, which clearly demonstrates the issue is not part of the IE driver, and the Java standalone server, which demonstrates the issue is not part of the Java language bindings or server implementation. Please retry your Selenium 3.5 test using a later version of IEDriverServer.exe. Failing that, we might be having to look back at webdriverio's wire protocol traffic (paging @christian-bromann).

xywang68 commented 6 years ago

Hi, @jimevans , I have ran the following (remote) scenarios: selenium-standalone-3.4.0 + IEDriver-3.4.0 = no error selenium-standalone-3.4.0 + IEDriver-3.5.0 = no error selenium-standalone-3.5.0 + IEDriver-3.4.0 = error selenium-standalone-3.5.0 + IEDriver-3.5.0 = error The logfile is to show the only difference is between selenium 3.4.0 and 3.5.0, where 3.5.0 shows the error. I also tried selenium 3.11.0 and IEDriver 3.11.0, and a few version in between, they all have this error. The test.js script does not use webdriver.io, it only uses selenium-webdriver. If you suspect the problem lies on node/javascript, I can run another java test. stay tuned.

jimevans commented 6 years ago

Sounds like we should probably rope in @jleyba too. The latest issue is almost assuredly something in the JS bindings. The original problem, I’m not so sure.

xywang68 commented 6 years ago

Hi, @jimevans , I have done a test with java, and found that with selenium-remote-3.5.1 (local) against selenium-standalone-3.5.0 + IEDriver-3.5.0 (remote) there is no issue. I have uploaded the test script and the selenium to the same gist. I support your thinking that this issue might be related to npm selenium-webdriver node/javascript binding, which also impacting npm webdriver.io.

xywang68 commented 6 years ago

@jimevans and @jleyba , any update on this issue?

barancev commented 6 years ago

selenium-webdriver node.js binding can't impact webdriver.io because it's an independent implementation.

xywang68 commented 6 years ago

Hi, @barancev , focusing on selenium and selenium-webdriver binding, do you see any resolution coming from your development team?

barancev commented 6 years ago

Not yet, I just noted that selenium-webdriver and webdriver.io are independent implementations, neither one affects another.

barancev commented 6 years ago

And, yes, reopening the issue for further investigation.

diemol commented 4 years ago

Is this issue still valid? There are recent alpha versions of the JS bindings that can be used to try again. In addition, the issue was reported with WebdriverIO as a client.

wahyubram82 commented 4 years ago

i test it using firefox 68.11, on facebook.

my step. identify every layer that contain post element. for any function that find elements base on class, tag, etc value inside the layer that contain post element. i success to identify.

but when i try search another element inside post element with search base contain text method, the result give me the text from another post (different lock element).

basically, facebook have similar structure for similar type of post. and have similar parents layer for every post.

with that condition, it's easy to identify every container that contains post. what we should we do is just set the crawler act like human behaviour in crawling to prevent facebook banned our account. this time I preffer not to choose search an element inside identified element base on text.

the similar structure of facebook prove that the element that already identified (lock), which working for another search method to search element inside that identified element (locked), not work for search element by text.

and yes facebook is smart, ex: detail post time, we saw it as a unity of text that we (human) can read it, but the truth is he put a single letter in many container (div) and set it with a specific regulation to make sure us (the user) can read it and crawler have a difficult time to identify it because set it with extra 'trap' which mean you can't just crawl the children elements and hope can read it after filtering, like 24 March, the children layer will result 2,4,S,t,M,t,S,a,t,S,r, etc..., you must do some extra 'translation job'..

hope you understood what i mean, i'm make a web too, so i understood how facebook web designer make his page, many layer over layer. but basically every web make a grand layout which set some main layer on it, and the web develpoer only need add another layer on it, so i call the grand layer that build the layout as container, because it lock the layer position on it. maybe similar like folium if you add many layer on it.

so the text search function should be search inside the layer that we lock it, but...it's not, the text result give the result from another layer. just try it with make a variabel that lock an element, and try search every text contain in that layer, it will be result many text, meanwhile inside that variabel only exist one text. e.g: 'Share' Text in facebook post.

diemol commented 4 years ago

Not sure how that is related to the issue, but is seems the main reason why this was reported is not relevant anymore.

Since we are doing an issue clean up, I'll close this one, but if the problem still exists, please create a new one with all the information the template requires.