I have an issue with Selenium Webdriver. I am running my automated test against a web application and have a test to check visibility of an element. When I run the same line of script in CLI
, the element is found and is_displayed()
returns "TRUE" but When I run it with other test cases through my Python IDE, is_displayed()
returns False
.
I tried implicit and explicit waits but wait is not the issue and the element is already loaded.
Here is the test case in my test script:
def test_image_element_icon_is_displayed(self):
self.assertTrue(self.driver.find_element_by_css_selector("#Image").is_displayed(),msg="Image is not displayed")
And this is script I run in CLI:
driver.find_element_by_css_selector("#Image").is_displayed()
Is there any way that I can prevent this false negative? Maybe changing the element selector I am currently using?
Here is the HTML of my Image element:
<div ng-click="applyDataElement(toolbarButton.type, toolbarButton.id)" class="frame-click ng-scope" ng-repeat="toolbarButton in toolbar">
<div class="frame-box" ng-attr-id="{{toolbarButton.id}}" id="Image">
<div class="draggable-box">
<div bind-html-unsafe="toolbarButton.icon" class="draggable-icon ng-binding"><i class="fa fa-picture-o"></i></div>
<div class="draggable-label ng-binding">Image</div>
</div>
</div>
</div>