Reputation: 946
I wrote some code to do repetitive tasks with the Webdriver in C#. My code works well on my PC but it is grabbing a different element on my boss's PC.
The element I'm looking for:
var InventMgmt = driver.FindElement(By.XPath("//*[@id='ROOT/Inventory Management']/div/span"));
This element is from a WebApp my company is using and it's the same across the network.
The problem is that the Webdriver is clicking a completely different element that is not listed in my code.
Both PCs are using the same Corporate OS (Windows 10), with the same browser versions.
After reviewing my code and Inspecting Element in my boss's browser, I'm starting to believe the issue can only be coming from my boss's PC...what could cause this kind of issue?
Here's the innerHTML of the elements I'm looking for and the one that are actually being clicked:
Trying to click the "Inventory Management" span:
<div id="ROOT/Inventory Management" class="x-panel x-panel-noborder x-tree x-panel-collapsed" style="width: auto;">
<div class="x-panel-header x-panel-header-noborder x-unselectable x-accordion-hd" id="ext-gen186" tabindex="0" role="tab" aria-expanded="false" style="cursor: pointer;">
<span class="x-panel-header-text" id="ext-gen190">Inventory Management</span>
</div>
</div>
Element being clicked is the div with id "ROOT/Support Table":
<div id="ROOT/Support Table" class="x-panel x-panel-noborder x-tree" style="width: auto;">
<div class="x-panel-header x-panel-header-noborder x-unselectable x-accordion-hd" id="ext-gen248" tabindex="0" role="tab" aria-expanded="true" style="cursor: pointer;">
<span class="x-panel-header-text" id="ext-gen252">Support Table</span>
</div>
</div>
Upvotes: 0
Views: 269
Reputation: 1063
You may want to check your browser 'Zoom Level'. It should be 100% for your automation to work as expected. I ran into a similar situation once.
I recommend restricting the driver from starting if zoom levels are not 100.
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
ieOptions.IgnoreZoomLevel = false;
IWebDriver driver = new InternetExplorerDriver(IEDriverFolder, ieOptions);
Upvotes: 1