Is there a native XPath support in Internet Explorer 11? - selenium

I have a problem with my Selenium tests when using IEDriverServer.exe (32-bit). The same tests work fine in Firefox and Chrome browsers, but fail in Internet Explorer 11 with diagnostics:
OpenQA.Selenium.InvalidSelectorException : The xpath expression
'//input[#id='username']' cannot be evaluated or does notresult in a
WebElement
It seems that IEDriver cannot find elements by XPath.
IEDriver version: 2.48.
Is there any workaround for this problem, except changing XPath with CSS locators?

I found a possible reason in comments for a similar problem:
here
Update for IE11 KB3025390 (and latest ones) breaks IEDriver. When uninstall updates IEDriver successfully interacts with WebElements through XPath.

Related

I am trying to use webdriver in the selenium module but I keep getting an error no matter what I'm doing

As stated, I am trying to use webdriver.Chrome in this sample project I'm doing but I am completely lost on what to do. This is the error I get error. But when I look at the version of chrome I installed, it seemed to match up. Chrome Version. Does anyone know what's happening? Sorry if the post is too unspecific.
You have to update your chrome browser. Try to update the installed chrome version to latest version.
To overcome this problem, use WebDriverManager: refer - https://bonigarcia.dev/webdrivermanager/ and https://github.com/bonigarcia/webdrivermanager.
If you are using Python with selenium, refer to this post for sample code:
Chrome with WebDriver--Why is it disappearing as soon as I hit "run"? Chrome Driver version 106 but Chrome can only be 105.0.9
If you are using Java with selenium, refer to this post for sample code:
element click intercepted in Selenium wedriver

Click method behaves differently when using ChromeDriver with Chrome and IEDriverServer with Internet Explorer 11

I have created xpath on chrome as :
"//a[#href[contains(.,'moduleCode=MASTER')]]"
This xpath is working fine for chromedriver. However, when the same Xpath is being executed for IEDriverServer it throws error as below:
org.openqa.selenium.ElementNotVisibleException: Cannot click on element (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.10.0', revision: '176b4a9', time: '2018-03-02T19:03:16.397Z'
But another xpath: "//a[contains(#href,'moduleCode=MASTER')]" works for both the ChromeDriver and IEDriverServer.
Not able to figure out why is there such difference in both the xpaths and why one of the xpath is not supported for IEDriverServer.
Capabilities used are as follows:
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
capabilities.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true);
capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true);
As mentioned in the Selenium Documentation,
At a high level, WebDriver uses a browser’s native XPath capabilities
wherever possible. On those browsers that don’t have native XPath
support, we have provided our own implementation. This can lead to
some unexpected behaviour unless you are aware of the differences in
the various XPath engines.
Taking a leaf out from #JimEvans's answer in this discussion:
The driver implementations for Firefox and Chrome are developed and maintained by the vendors for those browsers (Mozilla and Google) and those drivers have access to internals of the browser in ways that the IEDriverServer does not (and likely never will) have.
So there are some difference in the way driver implementations ideantify and click on elements.
Solution
While using IEDriverServer and Internet Explorer 11 Ensure that the nativeEvents capability is set to true.
capabilities.setCapability("nativeEvents", true);

Unable to install Firebug and FirePath despite looking for suggestions

I believe the default Selenium web browser is Firefox. My professor asked me to operate Selenium with Firefox version 43.0.1. Above it doesn't work, tested! However the issue is, I installed the latest version of Firebug and FirePath to get the XPaths. But it doesn't seem to work. Please help. I have read the earlier posts on a related topic in StackOverflow, still not working.
Firebug is officially discontinued. Though you don't need Firebug or FirePath to use Selenium.
Selenium also works with CSS selectors. Or, if you really need XPaths, you can copy them using the Firefox DevTools' Inspector.

driver.switchTo().alert().sendKeys("Hello") not working for latest chrome driver- Selenium Webdriver -java

driver.switchTo().alert().sendKeys("Hello")
The above code for prompt is not working for latest chrome driver with selenium webdriver -java. It didn't throw any error. Except sendkeys all other actions accept(),dismiss() , getText() is working well. I have used ChromeDriver 2.29, selenium-3.3.1, Chrome Browser - Version 56.0.2924.87.
google chrome
Version 59.0.3071.109
chrome driver 2.30
selenium 3.4
i have this version for chrome.
driver.switchTo().alert().sendKeys("Helllo")
is working properly.
This is purely a display issue and the input of sendKeys(...) will be sent after you accept the Alert.
See also the answer in this Chromium issue:
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1120#c11

How to replace Chrome with PhantomJS for use with Selenium and Conductor?

I am successfully using the Conductor framework to scrape data off a website. I use the Chrome browser and therefore I have installed chromedriver.exe in the root of my project.
To speed things up I want to replace Chrome with the headless PhantomJS browser. I installed PhantomJS as explained in the answer to this Stackoverflow question: PhantomJS & Conductor Framework and have changed the browser to Browser.PHANTOMJS in #Config.
Whatever I do however, I get no results.
I found no documentation how to setup PhantomJS for use with Selenium or PhantomJS.
The question How to Implement Selenium WebDriver with PhantomJS and Can we Use Sikuli with PhantomJS? did not help either.
How to replace Chrome with PhantomJS for use with Selenium and Conductor?
The trouble you are having appears to be due to an older version of the PhantomJS library included in Conductor. The error when running PhantomJS can be found in this imported issue on the Selenium Github. The remedy is to import a fork of PhantomJS which works with the newer releases of Selenium.
You can easily implement this by editing the pom.xml file and swapping
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>${phantomjs_version}</version>
with
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.1</version>
You can use a headless chrome driver with selenium, as showed here:
https://duo.com/decipher/driving-headless-chrome-with-python