Sarika Raheja
2016-06-10 11:23:01 UTC
Hi,,
Could pls someone clarify these doubts:
One webdriver script that i wrote is failing sometimes(not all the times i
run).
I feel the webdriver is passing the control to the next line of execution
even before the browser loads the page completely. And since the element in
that next line of code is not available that time,, the execution stops and
the browser closes before executing next 7-8 steps.
I am using Page Object Model (@FindBy) annotations.
I wanted to know if @FindBy implicitly/internally invokes implicit wait??
Or do i need to include wait in some other place/way?
This is how my code looks:
@BeforeMethod
public void preCondition()
{
String
browserName=GetData.fromProperties(".\\data\\config.properties","browser");
String url=GetData.fromProperties(".\\data\\config.properties","url");
if(browserName.equals("FF"))
{
driver=new FirefoxDriver();
}
else if(browserName.equals("IE"))
{
System.setProperty("webdriver.ie.driver",".\\browser_exe\\IEDriverServer64bit.exe");
driver=new InternetExplorerDriver();
}
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(url);
}
------------------------------------------------------------------------------------------
public class ImportDepartmentsPage {
WebDriver driver;
@FindBy(css = "a[id='btnDownloadTemplate']")
private WebElement clickingHereLink;
@FindBy(css = "a[id='btnImport']")
private WebElement importButton;
@FindBy(css = "input[id='Excel']")
private WebElement browseButton;
@FindBy(css = "a[id='btnClose']")
private WebElement closeButton;
@FindBy(css = "input[id='readOnly']")
private WebElement browseTextbox;
public ImportDepartmentsPage(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
public void clickClickingHereLink() {
clickingHereLink.click();
}
public void clickImportButton() {
waitForFileToBeSelected(browseTextbox,"value", "AddDepartments.xlsx");
importButton.click();
}
public void clickBrowseButton() {
browseButton.click();
}
public void typeBrowseTextbox(String loc) {
browseTextbox.sendKeys(loc);
}
public void clickCloseButton() {
closeButton.click();
}
public void waitForFileToBeSelected(WebElement element,String
attribute,String value) throws Error{
new
WebDriverWait(driver,30).until(ExpectedConditions.attributeToBe(element,
attribute, value));
}
-----------------------------------------------------------------------------
Could pls someone clarify these doubts:
One webdriver script that i wrote is failing sometimes(not all the times i
run).
I feel the webdriver is passing the control to the next line of execution
even before the browser loads the page completely. And since the element in
that next line of code is not available that time,, the execution stops and
the browser closes before executing next 7-8 steps.
I am using Page Object Model (@FindBy) annotations.
I wanted to know if @FindBy implicitly/internally invokes implicit wait??
Or do i need to include wait in some other place/way?
This is how my code looks:
@BeforeMethod
public void preCondition()
{
String
browserName=GetData.fromProperties(".\\data\\config.properties","browser");
String url=GetData.fromProperties(".\\data\\config.properties","url");
if(browserName.equals("FF"))
{
driver=new FirefoxDriver();
}
else if(browserName.equals("IE"))
{
System.setProperty("webdriver.ie.driver",".\\browser_exe\\IEDriverServer64bit.exe");
driver=new InternetExplorerDriver();
}
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(url);
}
------------------------------------------------------------------------------------------
public class ImportDepartmentsPage {
WebDriver driver;
@FindBy(css = "a[id='btnDownloadTemplate']")
private WebElement clickingHereLink;
@FindBy(css = "a[id='btnImport']")
private WebElement importButton;
@FindBy(css = "input[id='Excel']")
private WebElement browseButton;
@FindBy(css = "a[id='btnClose']")
private WebElement closeButton;
@FindBy(css = "input[id='readOnly']")
private WebElement browseTextbox;
public ImportDepartmentsPage(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
public void clickClickingHereLink() {
clickingHereLink.click();
}
public void clickImportButton() {
waitForFileToBeSelected(browseTextbox,"value", "AddDepartments.xlsx");
importButton.click();
}
public void clickBrowseButton() {
browseButton.click();
}
public void typeBrowseTextbox(String loc) {
browseTextbox.sendKeys(loc);
}
public void clickCloseButton() {
closeButton.click();
}
public void waitForFileToBeSelected(WebElement element,String
attribute,String value) throws Error{
new
WebDriverWait(driver,30).until(ExpectedConditions.attributeToBe(element,
attribute, value));
}
-----------------------------------------------------------------------------
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAGf9qkrO1DhQ1nJ72wQ3OxdhZEdP_h1w8GkvykUkG%3DOjsGK63g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAGf9qkrO1DhQ1nJ72wQ3OxdhZEdP_h1w8GkvykUkG%3DOjsGK63g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.