How to handle dialog box through selenium with python? - selenium

I am new in Selenium automation. Could you please explain me how to use this (if one exists) tag? It would be really helpful if you can give example.
The scenario where I am facing problem is: there is a save button, if we click on it a dialog box pops up. I need to enter some text in two text boxes and press save/cancel button on the same dialog. I am using Selenium as a tool and Python as a scripting language. Any help on this will be appreciated.
Thanks in advance!

sel.click("idOfSaveButton")
sel.wait_for_pop_up("popupWindowName", "30000")
sel.select_window("name=popupWindowName")
sel.type("idOfTextBox1", "someText")
sel.type("idOfTextBox2", "someText")
sel.click("idOfCloseButton")
sel.select_window("null")
You can also select the popup window using title=.

You can wait for the confirm box, then switch to it and do whatever you want. I asked familiar question before and the answer is here. Hope it helps.

Related

How to save a webpage with Selenium IDE using CTRL + S?

I am trying to emulate the ctrl+S to save the webpage as html but I can't make it work with Selenium IDE. I tried to look all over SO but there was nothing in particular about this.
I tried the following:
But when I ran the test, the popup did not show to ask me whether I want to save the page.
Am I missing something ?
Thanks in advance.
Maybe you can use something like Autoit to click in "Save" button that you can't reach with Selenium?

How to get driver when pop up appears - Selenium

I am finding difficulties to get the driver when popup appears. when I click a button, then it will open another browser window. can someone give me the tips how to get the driver on the popup browser? thank you
Please review again, this may be iframe, Please inspect with fire bug properly,and if page have iframe , then code with frame related property. If you feel again problem, please share the more information about code.
You can read more about iFrames and do something like this driver.switchtoiFrame. You will have to read its HTML to find it out if thats an iFrame, else if its a Pop-up then you need to switch to that Popup first

How to automate text writing in popup

I want to automate text writing in popup. Is it possible? if yes, then please guide me. Any help will be well appreciated.
If it's a browser popup, it sounds like you're looking for:
driver.switchTo().alert().sendKeys("some text to enter");
I got the solution:
driver.switchTo().frame(0);
driver.findElement(By.id("id of the view to enter text in the popup")).sendKeys("some text to enter");

Selenium IDE - record right click

Im using Selenium IDE for record test for my web app.
Selenium IDE do not recognize the right click in my div. I've customized right click over my div and I wanna test relative functions.
Can anyone help me?
Thanks!
Tommaso
Use 'contextMenu' / 'contextMenuAt' to do a right-click.
But as far as i know, you can not record that yet, so you have to add it manually.

Selenium IDE - Not capturing button link

In Selenium IDE, the application has got image as button. The click event for that is not capturing. Is there any alternative Selenium Commands available for that or otherwise, is there any JavaScript user extensions can be added?
Please help.
Thanks
Yes.. the image will act as a button..
Found a solution for that!!
Simply added a JavaScript code which supports clickAt() commands.
To detect button as image you can use one of the below solution
xpath=//img[#src='/images/logo_home.png']
xpath=//img[#alt='Home']
//img[#src='/images/logo_home.png']