I am trying to select option from the drop down in iframe but it is not getting selected.
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://verify-taxcerts.floridarevenue.com");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.switchTo().frame(driver.findElement(By.id("ivuFrm_page0ivu3")));
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.id("OFFM.SellerVerView.TaxTypeDDKey")).click();
driver.findElement(By.id("OFFM.SellerVerView.TaxTypeDDKey")).sendKeys("Sales and Use Tax");
Error
org.openqa.selenium.NoSuchElementException: Unable to locate element: #OFFM\.SellerVerView\.TaxTypeDDKey
Use case : i am trying to select option "sales and Use Tax"
what i am doing wrong ?
selenium version :3.14
ff : 70
Thanks
There's one more frame with isolatedWorkArea id:
driver.switchTo().frame(driver.findElement(By.id("ivuFrm_page0ivu3")));
// one more iframe
driver.switchTo().frame(driver.findElement(By.id("isolatedWorkArea")));
driver.findElement(By.id("OFFM.SellerVerView.TaxTypeDDKey")).click();
Related
I am writing a script to locate "login" and click on it for an web based application but I am getting exception:
no such element: Unable to locate element
My code:
System.setProperty("webdriver.chrome.driver","D:\\Selenium\\drivers\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.wayn.com"); //to find login
driver.findElement(By.xpath("//*[#id='TopMenu']/div[1]/div/div[2]/login-buttons/div/div[1]/div[1]"))
.sendKeys(Keys.ENTER);
Try this way.
driver.get("http://www2.wayn.com");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.xpath("//div[#class='button big left red ng-isolate-scope'][#wayn-log-click='loginButtonsLogClick']")).click();
Explanation of xpath: Use class and wayn-log-click attribute along with <div> tag.
Suggestion :- Instead of using absolute xpath, use relative xpath.
try waiting a little for element to be visible:
WebDriverWait wait =new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("username")));
driver.findElement(By.name("username")).sendKeys("username");
driver.findElement(By.name("password")).sendKeys("password");
The below script is working in firefox but doesn't work in Phanthon Js
driver.manage().window().maximize();
// Enter UserName
driver.findElement(By.xpath(".//*[#type='text']")).sendKeys("admin");
// Enter Password
driver.findElement(By.xpath(".//*[#type='password']")).sendKeys(
"admin");
// Wait For Page To Load
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
// Click on 'Sign In' button
driver.findElement(By.xpath(".//button[#type='button']")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement webElement = driver.findElement(By.xpath("//button[contains(text(),'OK')]"));
webElement.click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//span[contains(text(),'Process')]"))
Error
Caused by: org.openqa.selenium.NoSuchElementException:
{"errorMessage":"Unable to find element with xpath
'.//span[contains(text(),'Process')]'","request":{"headers":{"Accept-
Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-
Length":"60","Content-Type":"application/json; charset=utf-
8","Host":"localhost:32339","User-Agent":"Apache-HttpClient/4.4.1
(Java/1.8.0_60)"},"httpVersion":"1.1","method":"POST","post":".......
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Why Phanthon JS refused to work when it works fine using firefox web driver?
How to run the program headless i.e without browser which has the compatability with firefox webdriver code?
Alternative way to quickly prepare a script for headless?
I have already check and search for same question and there are lot of solution but no one is working for me so posing question here.
I am doing practice of selenium web driver. I am using this form for practice : http://www.toolsqa.com/automation-practice-form/
Now , I have 3 issues in that.
1 - There are first 2 links called "Partial link test" & "List test" which I am able to click on, using "findelement", but I want to open both link in NEW TAB in same browser.
2 - I am not able to upload file. My code is not working for that element.
3 - How can I select particular value from dropdown of "Continents"??
My code is given below :
WebDriver driver = new FirefoxDriver();
driver.get("http://www.toolsqa.com/automation-practice-form/");
driver.manage().window().maximize();
**driver.findElement(By.linkText("Partial Link Test")).click();
driver.findElement(By.linkText("Link Test")).click();**
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.name("firstname")).sendKeys("Tester");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.name("lastname")).sendKeys("Tester");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("sex-0")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("exp-2")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("datepicker")).sendKeys("01/01/1985");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("profession-1")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
**driver.findElement(By.id("photo")).sendKeys("C:/Users/Public/Pictures/Sample Pictures/Desert.jpeg");**
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(600);
driver.findElement(By.id("tool-0")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
**driver.findElement(By.id("continents")).click();**
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Please help to correct my code.
I have added the answers inline to each of your questions, below. Also, an advice, is to use Implicit wait only once at the top while creating a browser instance, as its scope is the whole class itself. So, once declared, then selenium will wait a maximum of that time, for detecting an element. It can be rather overridden by using Explicit waits for certain elements, if necessary Please see this link for better understanding Implicit and Explicit waits:
1 - There are first 2 links called "Partial link test" & "List test" which I am able to click on, using "findelement", but I want to open both link in NEW TAB in same browser.
//Clicking and opening Partial Link Text in new tab
WebElement element = driver.findElement(By.linkText("Partial Link Test"));
Actions act = new Actions(driver);
act.contextClick(element).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();
//Clicking and opening Link Text in new tab
element = driver.findElement(By.linkText("Link Test"));
act.contextClick(element).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();
2 - I am not able to upload file. My code is not working for that element.
The path of the file must be like this:
driver.findElement(By.id("photo")).sendKeys("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg");
3 - How can I select particular value from dropdown of "Continents"??
You can use Select class for that like below. It will select the option "Australia".
Select sel = new Select(driver.findElement(By.id("continents")));
sel.selectByVisibleText("Australia");
Open link in new Tab:
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,Keys.RETURN);
driver.findElement(By.linkText("urlLink")).sendKeys(selectLinkOpeninNewTab);
I want to click a href link, then go back to previous page, then click next href link which has text "Meer info".
I wrote following code, but it is producing an Exception. I can go to web then click first link that I want to click with text name "Meer info" than go to back but then I want to click second linkText also with the same text name "Meer info" but I don't know how to do that.
WebDriver driver = new FirefoxDriver();
driver.get("http://turksegids.nl/index.php");
Thread.sleep(3000);
driver.findElement(By.cssSelector("input[type='image'][value='Zoek!']")).click();
Thread.sleep(5000);
driver.findElement(By.linkText("Meer info")).click();
Thread.sleep(4000);
driver.findElement(By.linkText("Terug naar de resultatenpagina")).click();
Thread.sleep(8000);
driver.findElement(By.linkText("//a[text()=\"Meer info\"]/following-
sibling::a[2]")).click();
Thread.sleep(4000);
driver.close();
driver.quit();
I am getting this Exception
Unable to locate element: {"method":"link text","selector":"//a[text()=\"Meer info\"]/following-sibling::a[2]"}
You can use below code:
WebDriver driver = new FirefoxDriver();
driver.get("http://turksegids.nl/index.php");
driver.findElement(By.cssSelector("input[type='image'][value='Zoek!']")).click();
driver.findElement(By.linkText("Meer info")).click();
driver.findElement(By.linkText("Terug naar de resultatenpagina")).click();
driver.findElement(By.xpath("//*[#id='resultatenklik_28957_info']/u")).click();
driver.close();
driver.quit();
and see it works or not
Try to use
List<WebElement> element = driver.findElements(By.linkText("Meer info"));
element.get(2).click();
instead of
driver.findElement(By.linkText("//a[text()=\"Meer info\"]/following-
sibling::a[2]")).click();
It will work !!
I am working on a sample assignment on Thomson Holidays website (http://www.thomson.co.uk/holidays.html). On left hand side there is a Holiday Search panel. I am unable to recognize any of these elements in WebDriver. However, in IDE these elements are recognized. Need more info on this as it is the first time i am experiencing such an issue. Below is the code sample:
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://www.thomson.co.uk/holidays.html");
driver.findElement(By.id("searchbutton")).click();
driver.findElement(By.id("holidayAttribute_1")).click();
driver.findElement(By.id("holidayAttribute_2")).click();
driver.findElement(By.id("holidayAttribute_3")).click();
Thread.sleep(5000);
Because they're in the iframe, you need switch to the iframe first.
Two lines added to your existing code as follows:
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://www.thomson.co.uk/holidays.html");
// optional, unnecessary in your case
// driver.switchTo().defaultContent(); // make sure outside of all iframes
// switch to search frame
WebElement searchFrame = driver.findElement(By.cssSelector("iframe[src='/thomson/page/byo/search/usp.page']"));
driver.switchTo().frame(searchFrame);
driver.findElement(By.id("searchbutton")).click();
driver.findElement(By.id("holidayAttribute_1")).click();
driver.findElement(By.id("holidayAttribute_2")).click();
driver.findElement(By.id("holidayAttribute_3")).click();
The search panel is inside an iframe. As the iframe is the first iframe, you can use the below code.
driver.get("http://www.thomson.co.uk/holidays.html");
// switch to search frame
driver.switchTo().frame(0);
driver.findElement(By.id("searchbutton")).click();
driver.findElement(By.id("holidayAttribute_1")).click();
driver.findElement(By.id("holidayAttribute_2")).click();
driver.findElement(By.id("holidayAttribute_3")).click();