0

I have to check elements of an igniteBar on a webpage. When opened manually, the ignite bar appears with icons and operational (On mouse hover icon expands showing texts). Here is the html

<div class="IgniteBar" data-experiment-id=" ">
<!-- Used for A/B testing -->
<!-- Old IgniteBar -->
<ul class="IgniteBarV1 visible" data-total="6" style="">
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
<!-- New IgniteBar -->
<div class="igniteOverlay"></div>    
</div>

But when I open the same page through my Automation code using webdriver, the ignite bar is completely absent. Html that time is this:

<div class="IgniteBar">
<!-- Used for A/B testing -->
<!-- Old IgniteBar -->
<!-- New IgniteBar -->
<div class="igniteOverlay"></div>
</div>

I have applied all kinds of waits, thread.sleeps and the page loads completely, tried on faster network yet the behaviour is same - element does not appear through automation while manually it appears all the time. What kind of issue is this?

3 Answers 3

1

It could be issues with loading the element in DOM or may be that element appears once you preform action on some other element. So make sure you are going in right way as you are doing manually.

Introduce Explicit Wait here to check different condition.

To check whether element present in DOM :

new WebDriverWait(driver, 20).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("ul[class='IgniteBarV1 visible']")));

And to check visibility :

new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("ul[class='IgniteBarV1 visible']")));

In your case it seems visible attribute makes the element visible. So you can try to check whether element is there but not visible

new WebDriverWait(driver, 20).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("ul[class='IgniteBarV1']")));

And element present then check for visibility as below:

new WebDriverWait(driver, 20).until(ExpectedConditions.attributeContains(By.cssSelector("ul[class='IgniteBarV1']"), "class", "visible"));
1

If it's A/B testing, that means that sometimes feature is shown only for some users. You have two versions of website, and apparently your browser in Webdriver mode is not showing sometimes Old Ignite Bar.

It might be that you are logged in as you, and other users doesn't have that feature shown (are you using the same test user manually and in automated tests)?

In that case I would check in try catch for this, and after given amount of time I would go as the element is not visible on page (in that case there probably is a different way to do whatever you want to do).

0

It may be that the back-end logic is detecting the software making the HTTP request. If a browser is making the request, show the IgniteBar. If a bot is making the request, do not show the IgniteBar. A way to check this is to change the UserAgent string in your automation tool to identify itself as a browser instead of an Automation tool. You can find common UserAgent strings for various browsers and bots by Googling "UserAgent Strings".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.