Unable to click on Image icon which is displayed using WatiN - visual-studio-2010

I am using WatiN for automation.
I have a screen were two options are displayed "Search" and "Filter", with only one option enabled at once.
By default, search is enabled. I am able to click on "Filter" and perform filtering operations, but when i try to click on the search option (An Image) am getting a message as "Element is disabled".
Can anyone please suggest how can we click on a disabled image using WatiN?
This was working fine sometime ago, but it started failing at the point where i am switching back to Search.
Thanks & Regards,
Kumar

Can you post some of the code that you are using for these actions.
My guess is that you are identifying the search and filter buttons initially and at that time the search button is disabled. And due to some reason, the change in the DOM state is not reflected in the object. If my supposition is correct, either one of these actions might help
OPTION 1
Image search = // Identify the image button for search;
Image filter = // Identify the image button for filter;
/// Perform filtering ops
search.Refresh();
search.Click();
If this does not help,
OPTION 2
/// Perform filtering ops
search = /// Identify the image button from the DOM now;
search.Click();

Related

How to scroll to a particular co-ordinate in Test Complete

I have spied a notepad and text box of a notepad contains a string which will be visible only if you scroll down.
Now I am trying to perform a single click there via passing a rectangle co-ordinate to the Test Complete.So with that it is able to click if it is visible on the screen otherwise it fails saying :"there was an attempt to perform an action at a point which is beyond the screen"
Is there any way where we can scroll to the point of interaction before performing the action.
I tried with following steps to achieve that but its of no help.
testObj.setFocus()
testObj.hover()
testObject.MouseWheelScroll(an integer value)
Please try this..
testObj.scrollIntoView(true);
I'm using this code and this is working fine for me..

How to determine coordinates of an element with Watir Webdriver?

I have a problem. While parsing a page, a pop-up window appears and blocks access to html. I tried to click on the pop-up, but it re-directs me to a new page, and I have no clue how to get to the upper right area of the pop-up to close it. My question is how to determine the coordinates of that element? None of the related issues raised here at Stackoverflow helped me find a solutions, so assistance would be very much appreciated.
Why do you need the actual coordinates? That seems like a bad idea given it could move or have different results on different screen sizes (responsive designs). You'd be better off finding the class / id of the close button and calling browser.button(class: 'close').click or browser.link(class: 'close').click.
If you need help determining the class of the close button, open your browser and enable developer tools / console. They all have an inspector tool now to select the element and find all classes & ids.
In the unlikely event there are no classes or ids it may have a data attribute you could work off.
If the pop-up is a regular browser window you can close it by index. Your main window has index 0. So the pop-up has index 1.
if browser.window(:index => 1).exists?
browser.window(:index => 1).close
end

Getting the current value of a textbox in Access 2013 Custom Web App

in a List view I want a particular control (textbox) to have a red background color if it has a certain value. I have tried the following:
Click on the textbox then click the Data icon in the context sensitive controls that appear. I can then see that the name of the control is First_NameTextBox. I then click anywhere on the List view and click the Actions icon in the context controls that appear to the right of the view. I select "On Current". I then create two steps that should be executed whenever a new record is activated:
If [First_NameTextBox] = "somevalue" Then
SetProperty
Control Name [First_NameTextBox]
Property BackColor
Value #FF0000
End If
However, this turns the textbox red no matter what the value in First_NameTextBox is. How do I reference the CURRENT value of the textbox?
Conditional formatting based on a field value is not available for the List View in a Web App.
If you've built web pages (with or without a templating engine), the design limitations of Access can be frustrating.
Another kind of frustration comes from moving a form in Access from the native Access environment to a browser-based display.
I've felt the first kind of frustration, but so far I've avoided the second kind. I keep MS Access and HTML-rendered forms far away from each other.
Conditional Formatting in the List View of Access Web Apps is Available its just way harder than it should be.
Input "If Statement" under the "Current Macro" by clicking outside any text box or label then traveling to the top right of the view and you will see the Lightning bolt which allows two options, "On Load" and "On Current".
SELECT ON CURRENT
Don't forget You will need to set the control back to the original color by using the else. (also, for some reason I have to flip the Colors so where you would think red would go, Put White.
Example:
IF = "" True Then
White
Else
Red
END IF /DONT ASK ME WHY!
Summary: your Code is Sound, Just input it under the Views Current Macro Location
This is my first post, i spent DAYS looking for this information and found in the deep google somewhere so i hope this helps you.

Is it possible to find an element like a button and click it, when it is continuously moving on? e.g Carousel

I am using Selenium Webdriver(Ruby) to automate my web app and my web app has this carousel wherein my element continuously keeps moving in a loop.
By the time I locate that element and try to click it, element moves ahead.Hence I am not able to locate that element.
I tried finding and clicking that moving element by following code:
{
ele_button = driver.find_element(:xpath,"xpath")
sleep 10
ele_button.click
}
I thought that by 'sleep 10' I could make that element wait for 10 seconds and then click it.But this does not work and I am getting ElementNotVisibleError whenever I run my script.
Question:
Is it even possible to automate a moving element? If yes please provide me a solution.
Yes it is absolutely possible. I handled same scenario for carousel on my site. There are three ways:
Most carousel stop on mouse hover. So you may use it to stop the
carousel. Use Actions class to move over to the carousel. Once it
stops you may click on it.
If you want a specific slide, you can click on dots or any other navigator, like prev/nxt, to reach your slide and then click it.
The sure shot way to click your specific slide, without worrying about whether it is displayed or not is to use Javascript to click it (Which I had done in my case although I had also implemented 2nd way but I found javascript the simplest solution).
Why are the actions divided?
I would recommend the following:
driver.find_element(:xpath,"xpath").click()
so it will find the object and click on it.
Another thing you can do, as we doing in selenium with java that put the implicitlyWait according to the time on which your button came back after one rotation; now perform click just after implicitlyWait
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
// Suppose a rotation of button takes 30 sec
driver.findElement(By.xpath("/html/body/div[2]")).click();
// action performs on the element
In ruby you have to use this type of syntax
#driver.manage.timeouts.implicit_wait = 30

Why does a checkbox not remain checked in IE but not in FF or Chrome

i will make myself clear hope it will help to solve my problem
In my search engine i have the option to search some subjects from check box...it is like i have 10 check box with an option to choose some of the 10 check box and then to press search and i need to see some results....
now in IE after I press the search button i can see the results...
in FF after i press the search button the page load and it clear all check box i choose, and i need to choose it again....
hope i make my self clear sorry for my poor English
This sounds like normal behaviour. You will need to add checked to every check box you want checked, the browser is not going to do that for you based on previous selections.
The only exception to this rule is that Firefox will populate input elements with the previous values when you reload the page. You can't rely on this behaviour, though, and you should always use checked.

Resources